Talking to SerenityOS Contributors About a Scratch-built C++ Developer’s Playground in Modern C++
SerenityOS is a graphical Unix-like operating system for desktop computers. It’s also a great open-source project that proves that if you want to see something happen, you can do it yourself! In this interview, we talked to Andreas Kling, founder and main contributor to SerenityOS, and Linus Groh, another main contributor to SerenityOS, about the project itself, their experience with C++, and how CLion helps them to develop the project.
Hi Andreas, Linus! Can you please tell us a bit more about the project. What makes SerenityOS different from other OSes and what’s the overall goal of the project?
I started the project in 2018 with the short-term goal of keeping myself busy and the long-term goal of building an OS I would be able to use as my main system in the future.
We’re building a complete system from scratch in a single repository with no third-party runtime dependencies. That means we have our own kernel, shell, libraries, desktop, file manager, web browser, etc. It’s all written in modern C++20 with a custom standard library (not STL) used in both the kernel and user space.
Unlike other systems, SerenityOS is primarily made for its own developers. Everyone works on the things they are interested in, or the things they want to have in the system for themselves. There is no ambition to attract regular users, but everyone is welcome to join the development!
This autonomy also means that there’s no general roadmap or specific plans. While each individual contributor might have their own goals and TODO lists, there’s no guarantee that any features will be implemented at a certain point in time. In this project, the best way to make sure something gets done is to do it yourself!
At the moment there are no versions or releases either, as everything is still changing rapidly. To try the OS, the latest source code from the repository must be compiled locally – a process that has been made more and more convenient over time.
Can you briefly describe the tech stack you are using in SerenityOS?
The foundation of the system is a monolithic Unix-like kernel (x86 or x86_64) with a POSIX compliant C library as the low-level system API. This provides a familiar interface and allows us to run third-party software like GCC on SerenityOS.
The windowing system is implemented similarly to X11, with a control protocol that runs over local sockets, and bitmaps in shared memory being displayed by a compositing window manager.
You mentioned C++20. So you are on the latest C++ standard already. Right?
Yes, we’re using the intersection of C++20 that’s available in the latest versions of GCC and Clang. Since the project has no backwards compatibility concerns, we’re free to stay on the bleeding edge of C++ and we try to take advantage of this.
When I first came across the project, you were using Makefiles, but then moved to CMake. Why did you decide to do that? What were the major benefits of such migration?
There were two main reasons: dependency management and parallelism. With Makefiles, it was a constant battle to keep things building in the right order while spreading the compilation tasks across multiple cores. Moving to CMake was a big task, but one that has paid off greatly, both in terms of maintainability and build performance.
Andreas, in May 2021 you published a story about why you quit your job to focus on SerenityOS full time. How has it worked out for you?
It’s been absolutely great so far! Thanks to the generous support of people around the world, I’m able to put my full attention into the SerenityOS project.
The biggest difference I’ve noticed is that it’s much easier to tackle large-scale refactoring and less glamorous things like project administration etc. When I did this purely as a hobby, I had much less time (and energy) per day, so I preferred to spend it on “funner” tasks.
Andreas, I guess you’ve inspired a few contributors with your story. Do you know why people join the project? What drives them towards SerenityOS specifically?
This is one of my favorite things about this project: everyone has their own personal reasons for joining, but we all share a love for programming and curiosity about technology.
I like to imagine the project as a “developer’s playground” where people can learn how software works by building it inside a monolithic environment. Since we don’t use third-party code, there’s a strong feeling of cohesion within the codebase. It also creates a high degree of accountability within the project. If something needs changing, there’s no need to look outside for an answer.
Linus, you spoke in a recent CppCast episode about learning C++ with SerenityOS, as you’ve never developed in C++ before this project. Was it tough to get started with such a tricky language as C++ with its large heritage? How did you accomplish it?
It could have been much tougher in many aspects! I was by no means a programming beginner anymore, having learned and used various languages for various tasks over the years, so I no longer had to familiarize myself with basic programming concepts and could focus on the language specifically instead. This was no different. Initially, my entire goal in learning C++ was to contribute to this OS project that had been fascinating me for a while. This provided a lot of motivation, which of course helped me to keep going, even when progress was slow.
The timing also played a role. I dived into C++ in early 2020, right when the first lockdown started and I had plenty of time at home, which allowed me to spend more time on it than I would otherwise have been able to. Naturally, much of that time was spent investigating and debugging my beginner mistakes :^)
It’s also important to distinguish learning C++ in general from what we call “Serenity C++” – a subset of the language and using simple and understandable patterns – e.g. no exceptions, no STL, no consideration for compilers that can’t use the latest features.
Finally, being around C++ experts helped massively. Not only Andreas but many other contributors answered my countless questions or gave me hints when I knew what I wanted to achieve, but didn’t know what terms to look up (a common occurrence early on!) in the IRC channel and code reviews. It is a great environment for bringing both beginners in the language and experienced programmers – like me, and several others – up to speed.
Linus, what is the most challenging thing for you in the C++ language?
In the beginning it was definitely the compiler error messages, often many terminal pages long and not very clear about the true source of the issue. It’s become easier to grasp those over time, but in my opinion there’s still a lot of room for improvement in the various C++ compilers to show clear and human-friendly errors.
Nowadays I sometimes struggle with templates, one of the concepts uniquely new to me from C++. After learning a couple of different languages and using them for a while, many things are somewhat familiar in the next new language – but this wasn’t the case here.
I know you both use CLion for SerenityOS development. How did you start with CLion? What was your first experience like?
Earlier this year, I was looking for a new C++ IDE. I was already happy with my previous IDE, but I also wondered if maybe there was an even better IDE available, and I would never know if I didn’t try others.
So I decided to try something new, and the first one I looked up was CLion. One of the screenshots on the CLion website had a “SerenityOS” project on it, which was very surprising, and I thought this must be a sign! (I later learned that JetBrains had been using our SerenityOS makefiles for testing their makefile support.)
So I decided to give CLion a try. To be honest, it was a bit awkward at first until I got used to the keyboard shortcuts. But within a few days I was moving faster, and it felt really great. I’ve been using it every single day ever since then.
Like many other contributors, I started using CLion after seeing Andreas using it in his videos on YouTube – specifically after being offered a free license! I happily ditched my general purpose code editor that I had to configure to a point where it was usable for C++ development specifically, so I really enjoyed the “IDE, not just an editor” aspect of it. Everything worked out of the box, and the few add-ons I installed over time are not playing a part in my core development experience at all – I’d be totally fine without them.
What do you find the most beneficial in CLion for C++ developers?
I really like the fast and fluid navigation tools. Jumping to a specific file/class/function/etc. is super smooth. The integration of static analysis tools is also great. I love seeing tips from clang-tidy alongside compiler warnings.
Lately I’ve been using the 2021.3 EAP, and I’m a huge fan of the deduced type inlays for C++ “auto”!
I pretty much agree with Andreas here. Both the navigation within code and static analysis integration are great! Those clang-tidy warnings especially help me to avoid some pitfalls every now and then. I also regularly look up warnings when I come across them for the first time to learn more about the relevant issue. I generally find that the warnings give good advice, so they are part of my learning process :^)
Additionally, I rely massively on automatic code completion, which needs to be fast, accurate, and have an understanding of the language to be helpful – and in CLion it ticks all of these boxes!
Linus, as C++ was a new language for you, was it hard to get used to a new IDE at the same time?
Not at all! As mentioned, I had used a different editor (not IDE!) for almost a year after first starting to learn C++ before switching to CLion, so when I did I was already comfortable with the new language.
Additionally I had used both PyCharm and Android Studio for several years in the past, so there was an instant familiarity.
Can you please share some tips for other CLion users to get the most out of the IDE and your favorite action/shortcut?
One of my favorite shortcuts is Double Shift, i.e. the Search Everywhere functionality, which makes it incredibly easy to switch to files anywhere in the project or execute actions that would otherwise be hidden somewhere in menus. I cannot remember shortcuts for everything, so being able to search for them by name is helpful.
I also enjoy the Git integration, which is really well done. I’m nowhere near using the full range of available functionality, but everyone will at the very least need to commit, amend, and fix conflicts during development, all of which can be done without ever leaving the IDE.
SerenityOS is an open source project that falls under JetBrains’s OS support program, so now most active contributors to the project can claim a free license from us. Would you recommend that other contributors take this opportunity?
Definitely! I’ve been recommending it to people since I started using it myself.
Thank you both for the interview! And I hope you enjoy working on SerenityOS in CLion!
Subscribe to Blog updates
Thanks, we've got you!