CppCast - SerenityOS

Episode Date: December 17, 2020

Rob and Jason are joined by Andreas Kling. They first talk about the Qt 6.0 Release as well as another new C++ podcast that has been announced. They then talk to Andreas Kling about SerenityOS, the C+...+ Operating System he is building along with others in the Open Source community. News Qt 6.0 Released How to Make an Operating System using C++ New Channel from the JetBrains crew C++20 Published Links SerenityOS Serenity on GitHub Andreas Kling's YouTube Sponsors Visual Assist

Transcript
Discussion (0)
Starting point is 00:00:01 Episode 278 of CBPCast with guest Andreas Kling, recorded December 17th, 2020. This episode of CBPCast is sponsored by Visual Assist, the well-known productivity extensions for Visual Studio. Visual Assist speeds up development with features like smart navigation, code inspection and suggestions, powerful refactoring commands, and a whole lot more. Even spell checking and comments. Start your free trial at whole tomato.com. In this episode, we discussed the Qt 6 update and more C++ podcasts. Then we talk to Andreas Kling.
Starting point is 00:00:51 Andreas talks to us about the C++ for C++ developers by C++ developers. I'm your host, Rob Irving, joined by my co-host, Jason Turner. Jason, how are you doing today? I'm all right, Rob. You know, it's a good thing that you've managed to hold on to this first podcast thing because as we'll discuss in the news, we're starting to become inundated with C++ podcasts available. Yeah, that is very true. We recently had Connor on the show and him and Bryce are starting one. JF Bastion has a podcast and of course there's CBP Chat. So yeah, it's great to have more podcast content out there. I wonder if it's partially because of the pandemic that all these new podcasts are springing up? this kind of level of irony happening here right because we've had so many people tell us that they don't uh have a commute anymore so they don't have time to listen to cvp cast but since they're all
Starting point is 00:02:09 home i guess they have time to create their own podcast it seems that way or something yeah okay well at the top of every episode i'd like to write a piece of feedback uh this week we got this tweet from uh alif ur waga i apologize if i pronounced his name wrong we've had him on the show before uh but he wrote wait wait wait video on youtube when did that start i've just been doing the audio from the website and this was in response to uh me linking last week's episode which we do publish on youtube as well and yeah i don't know how oliver uh missed this but, we've been posting and recording video in addition to the audio for like the past year and a half, maybe.
Starting point is 00:02:50 At least, yeah, something like that. And that was the specific request from a listener who said that they can comprehend better if they can actually see people talking. And so we've tried to meet that when we can. Yep, absolutely. Well, we'd love to hear your thoughts about the show. You can always reach out to us on Facebook, Twitter, or email us at feedback at speedcast.com and don't forget to leave us a review on iTunes or subscribe on YouTube. Joining us today is Andreas Kling.
Starting point is 00:03:17 Andreas has been writing open source C++ for the last 15 years, working on projects like KDE, Qt, and WebKit. Nowadays, he puts all of his free time into Serenity OS, a new Unix-like operating system with the look and feel of a 90s office computer. Everything from kernel to web browser is done in-house in modern C++, and he frequently posts videos of his programming sessions to YouTube and wants to share a joy of programming with the world.
Starting point is 00:03:39 Andreas, welcome to the show. Thank you. Good to be here. That's an interesting background. KDE, Qt, and WebKit, were those all just hobby projects or were those any of that paid work? KDE was a hobby project and then I got picked up by Nokia. So I spent two years there working on Qt or Qt as we call it. And then I went to Apple and did WebKit for six years. Wow. So, um, but since then I've left the big tech industry. Nowadays I'm in the small tech industry in Sweden, um, chilling out. So we'll talk more about your
Starting point is 00:04:14 project SerenityOS in a minute, but I am curious, uh, if you still use KDE as your main desktop environment, um, when you're running Linux. I do not know. I use Mate on Linux. Mate? Which one is that? That's the, I guess, the continuation of the GNOME 2 project. Ah, okay, okay. Oh, yeah, yes, all right. I'm familiar with that now, yeah. I was so enamored with KDE back in the early 2000s. I would run it all over the place, and then I realized at some point, and I don't mean this is a knock at all to the KDE project because it's a very impressive project. I just wanted my desktop environment
Starting point is 00:04:49 to be simpler. So I just have XFCE everywhere now because that's just all I need. Anyhow, I just... Yeah, I feel that. Yeah, that's kind of the same thing that drives me to use Mate instead. I just want a very simple desktop.
Starting point is 00:05:02 Right. Okay. Anyhow, random aside. That's cool. All right, Andreas. Well, we'll start talking about Serenity OS in just a minute. But first, we've got a couple news articles to discuss. So feel free to comment on any of these, okay?
Starting point is 00:05:16 Sure. All right. And the first one is that Qt or Qt 6.0 has been released. I think we mentioned that the beta for it was out a couple weeks or months ago. But the whole, you know, the final release or the first release of Qt 6.0 is out now. And this blog post goes over some of the big changes that they made between Qt 5 and Qt 6. I didn't realize how long Qt 5 has been the main release. I think it said it was like seven years since Qt 5 and Qt 6. I didn't realize how long Qt 5 has been the main release. I think it said it was like seven years since Qt 5 was released.
Starting point is 00:05:49 Over eight years, yeah. Was it eight years? Yeah. Yeah, it was back when I was still at Nokia. We put that out. Yeah, I mean, and we've brought up Qt 6 a couple of times because I believe this also now brings with it the new license thing that had some people concerned. Mm-hmm.
Starting point is 00:06:03 Yeah. But one thing I wasn't aware of is it looks like they're uh making some big changes to the way they do graphics uh in q6 q5 i believe was all open gl and now they're trying to use metal and vulcan and direct 3d so i'd imagine you could get much more uh performant graphics out of q6 yeah, that's supposed to be one of the selling points of Qt 6, is that they've sort of unified their rendering abstractions to take better advantage of platform APIs. So nowadays it should be like on top of Metal and Vulkan
Starting point is 00:06:35 and all those things, right? And of course, also it's updated for C++ 17, I think is what they targeted. That one I find particularly interesting because, I mean, it's been a while since I've dug into the Qt source, but every time I have, I have to like, you know, as you see at the top of the file, like, if Qt namespace and then it pound defines what the namespace
Starting point is 00:06:54 opening would be there, and then down at the bottom again, whatever. And I'm like, okay, with C++17, have they just acknowledged that compilers now do support namespaces and have gotten rid of those macros, or are those still an option, depending on what the user needs? Oh, I don't know. I always figured those were for people who wanted to explicitly namespace the Qt library for themselves. So they wanted to like move it all out of the global namespace. Well, you've actually worked on these projects. I was always under the
Starting point is 00:07:19 impression it was because they still supported, you know, like GCC 2.0 or whatever back in the day, and it didn't have namespaces yet. Okay, I can't give an authoritative answer on that, actually. But I do remember that we had an absurd number of compilers and operating systems we supported back when I was there, like AIX and stuff like that. Right. I mean, you know, the ability to pull it into your own namespace could definitely be helpful depending on what you're doing, particularly if you have, because things happen in the real world, have to have two different versions of cute in your project or something. Yeah.
Starting point is 00:07:55 Okay. Next thing we have is a YouTube series that has started up somewhere recently. And this is how to make an operating system using C++. And Andres, I thought you'd be interested in this one. It looks like you're not the only one working on a C++ operating system out there. No, indeed. I watched the first video
Starting point is 00:08:15 and it looked like a nice little introductory tutorial to get started with something like that. I tend to focus more on what comes long after the introductory stuff myself. So there's not too much overlap with what I do. But it is nice to see that people are starting to realize that, hey, you can build operating systems with C++. Because for the longest time, there's been this meme almost that if you're going to do a kernel, you're going to do it in C.
Starting point is 00:08:43 And people are starting to wake up to using other languages, which is nice. For our listeners' sake, too, I think if you're interested at all in that video series, it appears that the author has given you something of a template to get started with EFI boot code and that kind of thing. So for people who have been curious about how to get that kind of thing going, you might check out those templates at the very least. Yeah, absolutely. It looks like a good place to get started. Yeah. Okay. And then yeah, Jason, as you mentioned, at the beginning of the show, and we're reading feedback, there is a new podcast out. And this is from Phil Nash and Anastasia from
Starting point is 00:09:21 JetBrains. And their first zero is out now. It's called No Diagnostic Required. Yeah, how did we miss that opportunity, by the way? We didn't do CBPCast episode, well, you, it was, I wasn't involved, but you went, you started with episode one instead of episode zero. That's true, that was a big mistake, yeah, yeah. And it was a huge mistake also for C++ Weekly. I started with episode one instead of episode zero, and I didn't even count in hex like i don't know like so this means phil is doing uh two different podcasts now because phil does cpp chat with uh with john culp still right yes yeah okay yes busy guy i'll be curious
Starting point is 00:10:01 personally to see how consistently regularly they get these released. Um, and I know because I watched this episode that Anastasia is still listening to CBP cast. So she'll probably hear me saying, I wonder how consistently they're going to release these. So we'll see what happens. Okay. they're going to release these so we'll see what happens yeah okay uh and then the last thing i want to mention is uh c++ 20 has officially uh been published and you can now actually go and buy or download the full uh pdf of the c++ 20 document i think you can also still find the the working draft if you don't want to spend like 200 bucks to uh to buy the pdf but it is available uh it's great to see that it made
Starting point is 00:10:50 it in uh before the end of 2020 yeah two weeks to spare yeah i like to refer to it as costing 200 units of money because depending on the exchange i mean it's officially 198 swiss francs but depending on the exchange rate at the moment within margin of error it's about 200 200 euro Swiss francs, but depending on the exchange rate at the moment, within margin of error, it's about $200, €200, €200. Whatever, it's fine. Are you going to buy a copy, Jason? No. No, okay. Download that working draft, though.
Starting point is 00:11:17 Yes, I don't know how many copies I already have of the working draft on my desktop here. What about you, Andreasreas any comment here um i'm just gonna wait and see what comes out in compilers yes i tend to find it easier to actually learn by testing stuff out myself right so i don't don't really get that much from reading those specs or standards yeah i only read it kind of like if I have to, like if compilers disagree or something or whatever, yeah. Makes sense. Okay, well, Andrus, we mentioned in your bio that you work on Serenity OS.
Starting point is 00:11:54 Could you start off by telling us a little bit more about what it is? Well, sure. So Serenity or Serenity OS is a new desktop operating system that I started writing in modern C++. And I started the project in 2018, after completing a three month long drug rehab. And I came out of there, and I didn't really know what to do with myself and all of my free time that I was now supposed to fill with something else. And I'd always kind of wondered what it might be like to build an operating system. So I just started poking around with some bits and pieces. And it wasn't really an operating system at first, it was an elf executable loader and a ext2 file system parser, and a little GUI
Starting point is 00:12:40 library with an event loop I was making with SDL. And at some point, I realized that, hey, if I just put a kernel underneath this, it will be kind of like an operating system. Just slap a kernel underneath it. Yeah, exactly. So that's how the Serenity operating system was born. And yeah, I named it after the Serenity prayer, which I had learned at rehab. And I wanted a name that would always remind me to stay on that healthy path and back then I was I was always worried about relapsing into bad behaviors and stuff so I wanted to build sort of these accountability mechanisms for myself so that's why I named the system that way and I also led me to
Starting point is 00:13:21 start uploading videos to YouTube of myself programming and just kind of stream of consciousness talking while doing it. And I figured that I had been sort of hiding my whole life. And I thought that if I just put myself out there and show my face on the internet, then maybe that will help me not hide so much anymore. And it worked out pretty well. So over time, people started finding the system and finding my YouTube channel, and somebody posted it to Hacker News, and then there were all these people coming in, and it was pretty overwhelming. My inbox was a disaster.
Starting point is 00:13:57 And I still have mails from them I didn't answer to. But the response to the system has been really great, because I guess it has this kind of scrappy can-do attitude that I wanted to build everything myself and not take in any outside dependencies. So the system is completely standalone other than the compiler. I was going to say, compiler? Okay. Not yet, anyway. Yeah, so that's what the system is, basically. And originally, it was just me for the first six months or so. But then people started finding it. And they found something they liked about it, and they wanted to participate. So
Starting point is 00:14:39 people started sending in patches. And I think we've now had about 225 individual contributors to something like that and um with about 15 or 16 of them with more than 100 commits um so it's a fairly active project today and it's going really well so how long has it been since you actually started it again if you don't mind um so i started it in october 2018 so okay it's a two years and two months something like that when did you say it got posted to hacker news uh that was in april of 2019 so yeah so the first six months i was uh just under the radar right uh just me committing and then people found it. I find these kind of, you know, overnight success stories interesting where usually there's at least six months to five years of hard work.
Starting point is 00:15:31 And then someone finds out about it and then it's an overnight success basically. But yeah, I think that's usually how it goes. Um, there was a lot of unglamorous, uh, nights in front of the computer, obviously to bring it to where it was after those six months. But I think something that spoke to people immediately was that I had a video presentation I had made just a couple of days prior to it showing up on Hacker News. So it was very easy to just link that and everybody could see the system running. And I guess it was a bit further ahead than you would normally see sort of hobby operating systems. So it captured people's imagination a little bit. And I also kind of think that almost all of us
Starting point is 00:16:14 have some sort of love for that late 90s graphical aesthetic. Because we all used Windows at one point or another in those days, and it has a special place in our hearts. So I think that spoke to people a lot. And do you do your YouTube videos live stream, is that what you said, or do you do them pre-recorded? They're pre-recorded, but I don't edit them. Effectively live stream.
Starting point is 00:16:39 Yeah, effectively. So when I first started doing it, I didn't have a good internet connection, so I actually had to record my videos and then drive into town go to the library and then upload there I was doing that the first couple of months wait you said this was 2018 right I just want to make sure I got the calendar right here yes yes it was um but I had I had rented a cabin over the winter so I was in this kind of remote location location and i would just drive into town to upload it was a simpler time the backstory that you shared is is fascinating to me so
Starting point is 00:17:15 it sounds like it has worked um the operating system has been a a distraction of sorts or a way for you to put your your time and energy um for you for the last couple of years. Yeah, it's, it's been really good. Um, I didn't know what to expect, so I figured I would just try a bunch of things and see what would stick. Uh, and it turns out that it sticks pretty well. If you just put your heart and soul into something. I have a, uh, I mean, kind of related story, but a friend who didn't realize he was an alcoholic until he started working out, basically. And then that became his avenue for getting out of his alcoholism, finding a place to put his energy. That'll motivate you right away if you're working out, yeah.
Starting point is 00:17:59 Right. So you've been working on the project for about two years now, And you said it's kind of come along a long way. What's kind of the current state of it? And what's on the horizon, so to speak? operating system that boots into a GUI, very similar looking to Windows 2000 or Mac OS 9, something like that. And it has a whole bunch of different desktop applications. We have, you know, file management, image viewing, stuff like that, but also a web browser, which I guess is the biggest individual application we're working on. And it's not like we're focusing on any one individual part of the system at the same time, it's more like very spread out and each piece is moving forward a little bit at a time and then they switch between the different pieces. So it's hard to get a grip on it if you're not like actively participating
Starting point is 00:19:06 in the development. But it's, I personally find it very impressive and very beautiful, but I'm also very biased. But it's, it's, it's, it's very nice. It's, it's gotten a lot more stable in the last couple of weeks, especially since some new people have come in and started taking an interest in working on some of the kernel stuff, like synchronization permittives and stuff like that, and improving stuff there. Because a lot of that was very slapped together by me
Starting point is 00:19:41 just trying to get to the next thing. I feel like that's the kind of thing, if you're not an expert in it getting it right is very difficult yeah yeah right but it turns out that you can usually get something working pretty well and then if you're just enthusiastic enough then eventually you'll attract someone else and they'll come and do it properly um so that's that's been really great. And there's a lot of really great people working on the project as well. So it's definitely not just me. I think we're about maybe 20, 25 people actively working on it. And everybody has sort of found their own little niche or their own little corner that they are particularly excited about in the system. So we have somebody
Starting point is 00:20:24 who's building a shell for it. And we have somebody else working on the kernel, somebody's really excited about JavaScript, spec compliance, and everybody sort of finds their own thing to deal with it. And I like to keep this philosophy that as long as people are doing the thing that they're specifically interested in, then that's when we get the best software. So I don't try to steer anybody to work on any specific thing, but just let everybody do what they want. And somehow, magically, it comes together nicely in the end. At least I hope so. I didn't realize. Oh, sorry, Ron. No, go ahead.
Starting point is 00:21:04 I didn't realize until we were preparing for this episode that you were working on Serenity OS and I actually have a friend who has been contributing for the last few weeks who has some spare time at the moment and his niche that he has found is going in and making things constexpr capable
Starting point is 00:21:21 that could be that would be Lenny yes he's also been on the podcast yeah he's been doing a great job with that uh and it's it's lovely it's like one of those things that's clearly helpful and beneficial but you need that that person to come in and be super excited about it to just uh go and do it everywhere and then it's it's really awesome when that person shows up so very happy about lenny well he said that it's really awesome when that person shows up. So very happy about Lenny.
Starting point is 00:21:46 He said that it's been a very fun experience because, like you were saying, as long as the code is clean or whatever and provides some benefit, you accept it. It seemed to be his impression. Yeah, exactly. I don't see any reason to not let people roam free, especially when we don't have any dependencies and we control everything under the same umbrella. It's very easy to iterate on something, even if it's not perfect. When it comes in, we can iterate.
Starting point is 00:22:15 I find that fast iteration makes people have more fun with it. Of course, we're still in a honeymoon phase. I realize that if at some point this becomes something that we have to make releases of, we might have to calm down a little bit. But we're far from there. So that's all good. I want to interrupt the discussion for just a moment
Starting point is 00:22:39 to bring a word from our sponsor, Visual Assist. Visual Assist is used by serious C++ developers across the world. It's got great code generation. Do you need to implement methods from an interface? What about changing a pointer to a smart pointer, even an Unreal Engine smart pointer? Adding a symbol you've typed but haven't declared? Visual Assist will do these and much more. Plus refactorings, more powerful than the ones included in Visual C++. Or detecting errors in code and suggesting useful corrections, or navigation, helping you move anywhere in your code and open or locate what you need,
Starting point is 00:23:14 or even the debug extensions. Visual Assist is written by C++ developers for C++ developers. It includes everything you need and nothing you don't. It has a low UI philosophy. It won't take over your IDE, but will show up when useful. It's there to help, not to advertise itself. Visual Assist is relied on by the developers building software you've used. Whether that's office suites, operating systems, or games, software you use was built with Visual Assist. Get the same tooling for your own development. Visual Assist supports Unreal Engine 4
Starting point is 00:23:37 and many versions of Visual Studio, including VS 2019 and Community. Get it at wholetomato.com. What is it like to kind of get started if you're interested in contributing to Serenity OS? I mean, I've never worked on an operating system. Like I have no idea what type of build time it looks like, what debugging on an operating system looks like. Can you tell us a little bit more about that? Sure. Yeah. So to people who are interested in contributing, I always tell them to just build a system and try it out and then see if you find something broken or something that annoys you and then just try to fix that. And that turns out to
Starting point is 00:24:17 be pretty good because then everybody just takes their own perspective on it and they find all kinds of interesting things that i would never have thought were annoying um and i think one thing i would like to do with this project is just expand people's idea of what an operating system is because um to so many people an operating system is a kernel right and i think there's so much more to it than that so i come from a background in kde and i also worked on mac os and ios at apple so for me an operating system is really like the whole stack like the kernel the shells the user land utilities and all the gui and everything there um so that's how we're building serenity os so it really does have everything from the kernel to the like the javascript engine
Starting point is 00:25:01 in the web browser and the you know the png JPEG decoders, all that stuff. So whatever you would want to work on, it probably has a space and a place in the system. And since we're doing it this way, we're also able to use the same sort of libraries for everything. So that works out pretty nicely as well, because once you become familiar with some part of the system, then you can bring a lot of that comfort with you to any other part. So one of the funnest things for me to see as sort of the spider in the project is to see somebody coming in, working on their little specific thing, and then they just branch out suddenly and jump from JavaScript to kernel. And people are just pushing far outside their comfort zone because the project allows them to do that. So yeah, if you wanted to work on it, you could do literally anything.
Starting point is 00:25:55 It would probably fit. Your JavaScript engine, your libpng, your JPEG parser, you're saying all of that is from scratch internally. That's right, yeah saying all of that is from scratch internally. That's right. Yeah, all of it. And I started most of the libraries and stuff, but not all of them. So by now, a lot of other people have started new libraries for it as well, which is really nice because then I don't have to feel as responsible
Starting point is 00:26:20 for everything that breaks all the time. That was a bit difficult early on they're like whatever was broken it was always my fault right but we've moved on from there now it's maybe like 60 percent of the time it's my fault um but yeah okay uh what hardware are you able to run Cerny on oh that's that's a good question so the short answer is I don't really know, because I haven't tried that much hardware. We tend to do most of the development on emulators,
Starting point is 00:26:53 just because it's so convenient, especially for iterating on stuff like kernel changes. And since the system is so fast to boot, like it boots in a split second, you can even work on a GUI application And since the system is so fast to boot, like it boots in a split second, you can even work on a GUI application and not feel sort of restricted by the fact that you have to boot a VM every time you change
Starting point is 00:27:13 a single line of code, because you can be back in that GUI like in a few seconds, even after a rebuild of the whole kernel. So most of the development happens on emulators. So the hardware we support really well is whatever QEMU emulates, essentially. And VirtualBox and VMware, I think some people got it running there. But then at the same time,
Starting point is 00:27:35 a bunch of people are enthusiastic about this and they have gotten the system running on their random PC boxes that they cobbled together. And just a couple of days ago, someone in the community started working on a hardware compatibility list for the system, where he's just adding the individual pieces of hardware that he got to boot on.
Starting point is 00:27:56 So it's a very short list so far, but I guess we're looking forward to expanding on it. It is very, very lacking in terms of hardware drivers. Like it's not an area that we have put much effort into at all. Almost all the effort has been on building out like a user land and just the core of a kernel. But something I find very interesting about this project is that while all of the code is original and new, we're using almost all of the abstractions, all the abstractions that we're using almost all like tried and true and proven abstractions, right. So we're using a POSIX,
Starting point is 00:28:36 like kernel, and we have sort of event loop driven GUI and all these things. So we know that you can build software this way. So you can go and build something halfway in the kernel. And then as long as you can move the user line and keep building there, you don't have to finish everything perfectly in the kernel. So you can sort of move in between the different abstraction layers, you don't have to finish everything. So that has been really helpful for building the stack vertically. And then sort of someone comes in later and says, oh, wait a minute, there's a corner case in the few text here, and they can go and spend a week trying to figure that out.
Starting point is 00:29:12 But it didn't stop the development of a web browser. So you've got a file system. You said it started out as ext2? Yeah, that's right. Okay. And you said someone's working on a shell. So do you does there a working shell at the moment? Yeah, yeah, we have a working shell and working terminal emulator and everything. So we even have a telnet server. And you can tell it into it, although it's a little bit shaky sometimes, because there are some issues with the TCP implementation.
Starting point is 00:29:46 So if you stay on your telnet session for too long, it might get a little flaky. But it grows more stable over time as more people use it. We're kind of shaking out the problems. And something that has been really cool recently is we started fuzzing a lot of the system. I was so going to ask about that. Go for it.
Starting point is 00:30:11 Obviously, in a Greenfield C++ project, fuzzing is going to find problems. It was not super surprising to us when it did. People started building fuzzers. The way we do it is that we build parts of the system on Linux, and then we fuzz those parts there. Okay. And that allows us to integrate with now we're on this Google cloud fuzzing thing, OSS fuzz. So they are continuously fuzzing a whole bunch of our libraries, and we can easily add more by just tweaking a build script on our end.
Starting point is 00:30:46 So that has already sussed out a couple of dozen bugs in our parsers and image decoders and stuff like that. That's what I was going to ask about the image decoders. Yeah. Yeah, yeah. It turns out that broken image binary formats are just very fuzzer friendly. But hopefully we found all the basic bugs at least,
Starting point is 00:31:13 but we still have a backlog. And one thing I think that we did maybe a little bit unusually compared to other users of OSS Fuzz is that when they added us, I asked them to just make all the issues public because we don't really have releases, so we don't care if everybody can see what our bugs are, and they were not really equipped to make issues public. So now we still have to add everybody's email if they should be able to see the issues.
Starting point is 00:31:43 That's something i hope might change someday because we have nothing to hide like we're not ashamed of our bugs we just want to fix them yeah that sounds like something that a lot of open source projects would would want to be public i feel like i mean maybe not all because you know like lid png i feel like this is one of these where if there's a if there's a security flaw in its parser, then the internet breaks, right? Like literally every device is susceptible at that point. So maybe that shouldn't be public, but on a case-by-case basis anyhow. Yeah, I mean, I guess they're just erring on the side of caution with this.
Starting point is 00:32:20 It's easier to selectively open than it is to retroactively try to close it down once something comes out right so can the operating system host the compiler itself like if i'm working on the web browser do i compile inside of serenity or do i compile outside serenity so you compile outside um but we do have a working port gccCC, and the binutils and everything, so you can compile inside the system if you want to. It's just so much more convenient to use my IDE outside still. Oh, you have imported CLion or whatever?
Starting point is 00:32:55 No, actually, I'm building my own IDE. It's called Hack Studio. OK. And I'm trying to make it comfortable to work in, but some things are just so nice I use Qt Creator as my IDE and the auto-completion C++ support is just really good so until we have a C++ parser
Starting point is 00:33:17 it's just unlikely to be as comfortable working inside the system so for long-running development tasks I tend to be outside but i've done a couple of sort of stunt videos where i just spend 45 minutes in the system building out something so i did a breakout game in hack studio a couple of weeks ago from scratch like working in the system the whole time and that worked out pretty well it's uh it's weird to write c++ without autocomplete but i hope I don't have to get too used to it. That's funny, because I've only just very recently started using IDEs for my C++ development,
Starting point is 00:33:54 so I'm used to not having autocomplete. Sometimes I feel like it gets in my way. Yeah, I can relate. I used to be that way, too. And at some point, I got comfortable. I think it was like whenever you have to learn some new library quickly, then it's just so nice to have autocomplete when you don't quite remember all of the APIs and stuff
Starting point is 00:34:13 and you don't remember the parameter order. Right. Totally agree. So you talked a little bit about fuzz testing. Do you do any other testing on Star Energy? Do you have unit tests set up, integration tests, anything like that? Sure, yeah. So we have a bunch of unit tests that we run. We're using the GitHub Actions for our continuous integration.
Starting point is 00:34:35 So the shameful thing is that we're still not actually booting the system to run the tests, but we're compiling all of the unit tests for Linux and then running them there. Okay. Okay. But we're still able to cover a large part of the code base. And since it is a POSIX system, it is pretty easy to move code back and forth. And we have been putting some effort towards making the kernel testable as well. And it's like we have all of the pieces, but we need somebody to hunker down and actually put them together
Starting point is 00:35:07 and make the test run. That is definitely something that we need to do at some point. But it sort of goes back to my philosophy of having everybody work on the thing that they feel is the most interesting. So just kind of waiting for somebody to pick that up. So is that the philosophy then that you maintain for yourself when you go to do your programming session for the day, you just work on whatever sounds interesting at the moment?
Starting point is 00:35:33 Yeah, absolutely. Because I would rather make a video of myself building some insignificant GUI detail and being really enthusiastic about it, than to try to force myself to do something really interesting or advanced. Sometimes it's just me like, oh, I'm going to add a line between these two gooey elements here, and welcome to the video about that. I mean, I try to make it a little bit non-trivial, but sometimes it's just, it tries to be an honest depiction of what I actually do, right? And something that is important to me is to keep a high quality of graphical interface.
Starting point is 00:36:14 That's always something I've felt is lacking in the Linux world, that the GUI is very sort of fragmented and it's hobbled together from parts that use different frameworks. And there's no cohesive vision feeling to it. And especially from a background in KDE and macOS and iOS, there's this extreme cohesion. So I'm trying to bring that into SerenityOS as well. So everything is written in the same way, in the same style, tries to look the same, feel the same. I think it makes the whole feel more like this, more than, what is the expression?
Starting point is 00:36:52 Like more than the sum of the parts. The sum is more than the parts. Right. Exactly. Yeah, it's a difficult one. Whatever that is, that's what I'm going for. Did we ask yet what version of C++ is Serenity written in? No, you didn't. So it's written in C++20, I would say.
Starting point is 00:37:11 But our use of C++20 features is kind of limited just because we didn't start busting them out yet. But since we have no dependencies and nobody really depends on us, we can just stay on the bleeding edge of the compiler and um we're using gcc 10.2 at the moment which is their latest release so 11 will be out soon yep looking forward to it um we recently started using a little bit of concepts to constrain some stuff which was nice. And then it broke building on Mac
Starting point is 00:37:47 because some people build on Mac with Clang. And then there was some whole thing with that, that didn't quite support what we wanted to do. So there's that tiny, tiny little constraint with some people wanting to build on Mac, but hopefully Clang will catch up release wise soon. We can stop worrying about that. But yeah, we're using C++ 20, although personally, I haven't looked too much into what's actually available. I mean, I know the big stuff like the spaceship operator that everybody is excited about. And I like the idea of modules. I'm just waiting to see what it actually
Starting point is 00:38:20 looks like when it comes out. And concepts have been useful so far. But we'll see. I don't know. Are you guys excited about some particular part of C++20? The main thing that I find being helpful to my code is concepts at the moment. But yeah, getting something that doesn't ice either GCC or Clang,
Starting point is 00:38:39 once you get it on one or the other, can be difficult depending on what you're doing. I wouldn't be surprised at all if you have some C++20 constexpr code in there from what Lenny was doing. Oh, that's very possible. Yeah. And oh, and another thing, we've also been using templated lambdas in some places, which I didn't even realize was a C++20 feature until Clang Tidy, I think it was, told me that it's not supported and I had to figure out why. Nice.
Starting point is 00:39:16 What do you find is, as someone who has experience working in KDE, I guess, just what do you find most different about working in a C++ operating system compared to working on a Linux C operating system? I guess the transparency of it all. Because when I worked on KDE, I always felt like there was like a hard floor where I couldn't really see below it because I didn't look much into the kernel. I didn't look much into X11, right? Better off for it, probably. Yeah, maybe. Very possible.
Starting point is 00:39:54 But nowadays, now that I know the whole stack, it does give me a lot of confidence to maneuver in ways that I never really felt like I could before. So we've been building some quite nice vertical integration stuff that we're able to do because we control the kernel and the window compositor and everything, right? So for example we've adopted the Darwin-style purgeable memory, which is this mechanism where you can have a piece of memory that you can mark as volatile, and then the kernel is free to yoink it away from you at any time. And if you mark it as non-volatile, then the kernel will leave it alone. So it allows you to sort of manage caches of large memory objects and sort of tell the kernel about when you need it and when you don't.
Starting point is 00:40:45 And we're using that to great effect in our windowing system, for example, as window backing stores. So if a window is completely obscured by another window, then we can make that window backing store, the obscured one, we can make it volatile. And if the kernel is running low on memory, it can just go and take that memory away from that window. And the windowing system doesn't have to know anything about it.
Starting point is 00:41:07 And it turns into a very nice memory optimization and a responsiveness optimization. And I would never have known how to do something like that while working on KDE, because it needs tight vertical integration all the way down to the kernel. So you do have a regular job also at the moment? Yes, yes, I do. I work on industrial networking hardware at a little research lab in Sweden.
Starting point is 00:41:35 So we're doing some experimental 5G products for the industrial customers. But it's a small tech industry, not the big one. Or the industry is big but the tech is small right do you find that this operating system development is influencing your regular work at all um i guess in in the way that it makes me feel um fearless like knowing how to build a whole stack for myself it gives me confidence to to poke and prod at any part of another stack so now nowadays if i wonder something about how does linux handle this i feel much more confident going into the linux kernel and looking what they actually do right
Starting point is 00:42:18 because although the serenity os kernel is much less mature and not designed in the same way it's still like that familiarity allows me to to reason about what they're doing and um that has made some things a lot easier to understand is there any part of the serenity os that you cannot write in c++ um sure yeah the um you never quite get away from inline assembly when you're doing an operating system because you just have to interact with the CPU at some point. But there's surprisingly little of it. There's stuff like entering into a syscall or setting up the stack for signal handlers and stuff like that. Like this really, really low level CPU specific stuff. But it's not too much. And we're kind of suffering from the same problem
Starting point is 00:43:09 that early Linux had that we targeted x86 processors. So the whole thing is sort of built around x86 concepts. And at some point, we realized that, well, that's not great if we want to expand to other architectures and now we have to start abstracting things but um it's not too bad is that something someone's working on right now you could loosely call it working on yeah okay it's sure yeah it's something that that's moving slowly forward somehow that was just an idle curiosity of mine is you know what would be involved to get it ported to arm or something like that, but it sounds like you're trying to figure that out right now, basically. Yeah, well, I can say that somebody has sent me a diff of a working ARM port that boots the kernel on ARM, but it was in very bad shape, and then the person disappeared.
Starting point is 00:44:03 So he just said, hey, this boots on ARM, and then I person disappeared so uh he just said hey this boots on arm and then i didn't hear from him about that again but maybe he'll be back it didn't look terribly complicated um but it also didn't look terribly functional so we'll see right um i know you said you yeah go ahead i was gonna say i know you said you encourage you know just try out the project, try building it, see if they find something that interests them. But are there any specific areas of Serenity that you're hoping to find more contributors to work on? Not really. I'm just happy if people find something that they're interested in working on. If it takes us 10 years to get this thing into shape,
Starting point is 00:44:46 then that's the time it takes. I would rather take a long time building it and having fun the whole time than trying to herd people into building the right thing at the right time. Do you have a Doom port yet? Definitely. Of course, we have Quake too.
Starting point is 00:45:04 Doom is like notoriously easy to port to new uh to new operating systems so i've been surprised if you didn't yeah yeah indeed although we don't have sound for doom is that because you don't have sound or because doom port doesn't have sound the doom port that i ported didn't have sound support. And I didn't look super closely at how to do that. And then we got Quake running, so that has sound. And then I kind of forgot about Doom. Okay. Yeah, sound is one of those things that I didn't know anything about sound
Starting point is 00:45:42 before starting on Serenity, and I still know almost nothing about sound programming. So I had to learn a lot just to get that running at all. That's been fascinating. I'm definitely learning so much on this project, like I don't want to give anyone the impression that I know how to do all these things because I don't. Like I'm discovering as I run headfirst into the next thing what it actually entails and what's required. And I'm just so used to being in over my head at this point that it feels normal. What is that process like?
Starting point is 00:46:13 Because you're building all these low-level libraries on your own. So how do you go about figuring, how do I write libpng from scratch now? Yeah, okay. So libpng, I just started by getting the png spec. And I made a one by one pixel white png. And then I just started writing code until I could load it. Okay. And then once that worked, that I've made a larger png. And then I made one that had alpha, and alpha channel and so on. And then eventually, it was so good that I tried to download a PNG and load it and of course it crashed and turns out that PNG has all these different interesting features but really it's
Starting point is 00:46:56 a very incremental process of just trial and error and learning and having this sort of willingness to do something in a bad way or the wrong way at first and just persevering and improving it incrementally. And that's something I always try to encourage people to. And part of what I try to do with my YouTube channel is to show people that even with experience, you don't necessarily know how to do something properly the first time you can, you can sketch out a crappy version of something and make it work and then start iterating on it right so most of the system
Starting point is 00:47:30 has been built in that way and just doing it in some crappy way that works and then figuring out what's the nice way of doing this what's the name of your youtube channel by the way i don't think we've mentioned that yet uh my youtube channel is my name so so Andreas Kling. It's just youtube.com slash Andreas Kling. They chose the name for me based on my Google username. Right. Just wanted to make sure our listeners, since we've mentioned it like five times now, could find it if they wanted to. Sure, yeah.
Starting point is 00:47:56 Thank you for reminding me. So I want to come back to the browser, if you don't mind, because I just actually did a somewhat tongue-in-cheek twitter poll where i said what operating system do you run and i listed you know chrome firefox edge right because our web browsers are i'm i would say it's easy for me to believe that a web browser is actually more complicated than your operating system right like because they've got so many things that they have to do, at least if you include all of the PNG libraries
Starting point is 00:48:29 and all that kind of JavaScript engine and everything in there. I'm just curious what status it's at. How well does it work and whatever? Okay, so the status is that it is a basic CSS2 implementation. Okay. So it's pretty far behind in terms of modern CSS features. But it has bits and pieces from more modern specs at the same time. So it's not like we targeted any individual spec. It's more like, hey, let's try to load Reddit and see what breaks.
Starting point is 00:49:00 Okay. Add whatever is necessary and then move on to the next website so it's very organic anything that takes in data from the outside we build organically by just throwing data at it and then hacking until it works and then try to retroactively come up with good abstractions afterwards after we get something working but it is a decently competent HTML and CSS engine.
Starting point is 00:49:25 It can do basic pages. Like you can go and load a media wiki or Reddit page or something like that. Uh, but it has very, very noticeable layout flaws. Um, things don't line up the way they're supposed to and margins and padding and everything is off everywhere. But, um, these are all things that, that we can iterate on and fix. Right. But these are all things that we can iterate on and fix, right? And the JavaScript engine is very slow. We're still focusing on just bringing up all of the language features.
Starting point is 00:49:53 So we don't have a JIT or anything like that. It's just a straight interpreter. But it parses and runs a fairly large part of ECMAScript with some pieces, some big new features are missing, like await async, promises, stuff like that. But again, it's just waiting for somebody to pick it up and say, oh, I'm going to make promises work. And JavaScript is probably the best tested feature we have because something that happened was I started building the browser without a JavaScript engine.
Starting point is 00:50:30 And people kept asking me, are you going to add a JavaScript support to this browser? And I would just always sort of ignore the question. But at some point I realized, okay, maybe it's hard to build a JavaScript engine, but I should probably try because how hard can it really be, right? So I just made a video of me starting to sketch that out. So I just hand wrote an AST in a video and then made an interpreter walk the AST and run the code. And something happened to some of my viewers that were JavaScript developers that they became super excited because they saw that, wait a minute, you can build a JavaScript engine? And they wanted to participate in that.
Starting point is 00:51:10 So a lot of the lib.js engine that we have has been written by people who were originally web developers, but then they just got so interested in this that they wanted to learn more about it and participate in the construction of a new JS engine. Wow. And yes, it's been really awesome to see people come out of their shell as developers and sort of expand what they thought they could do.
Starting point is 00:51:36 And they also brought a lot of nice JS experience because I don't have a lot of JS experience. So they've built this really nice unit testing framework for us. And then they keep adding this really nice tests when they make engine changes. And they put me to shame because I write these simple little unit tests to test like the one thing I'm changing, and they're coming around with this hundred line tests. That's very good. Sounds like potentially a lot of fun. I'm hoping some of our listeners have said, oh, well, I've always wanted to do, you know, whatever. I know when Rob asked you where you're looking for help, and you said you don't really want to guide anyone in a particular direction. Maybe if I could try rephrasing that question saying you've mentioned lots of things the operating system has. Is there anything that it does not have at all yet um yeah many things it doesn't have png writer for example we can't save pngs it doesn't have a c++ parser for our ide so we could do code completion there um pdf support it doesn't have pdf support um and it does not have many hardware drivers at all.
Starting point is 00:52:46 It has no MP3 decoder. Um, MP3 decoder. That could be fun. That might be fun. Right. Um, it has no, no way to play Spotify music, which I would personally like. What about, uh, don't know what goes into that, but just open GL or any kind of 3D capabilities? None whatsoever, yeah.
Starting point is 00:53:07 There's a huge area there that you could get into. It also doesn't have stuff like 64-bit support in the kernel, so we run the CPU in 32-bit mode at the moment. Interesting, okay. Just because it was what I was familiar with when I started the project, so I just wrote it out that way. It's one of those things that people ask about like hey when are you going to add 64-bit support and the answer is same as to every other question which is when somebody picks it up okay um but yeah it really is open um and just because i can't think of
Starting point is 00:53:43 something that's missing doesn't mean that you can't right maybe that gave some listeners some ideas yeah okay well andreas it's been really great having you on the show today uh it sounds like a really fun project and and thank you for kind of opening up about what brought you to start work on this project it's a great story yeah sure yeah happy to share awesome And where can people find you online? So I'm on Twitter as Awesome Kling because Andreas Kling was taken. And you can find the operating system on serenityos.org. All right.
Starting point is 00:54:17 Thanks, Andreas. Thanks, guys. Thanks. Thanks so much for listening in as we chat about C++. We'd love to hear what you think of the podcast. Please let us know if we're discussing the stuff you're interested in, or if you have a suggestion for a topic, we'd love to hear about that too. You can email all your thoughts to feedback at cppcast.com.
Starting point is 00:54:40 We'd also appreciate if you can like CppCast on Facebook and follow CppCast on Twitter. You can also follow me at Rob W. Irving and Jason at Left2Kiss on Twitter. We'd also like to thank all our patrons who help support the show through Patreon. If you'd like to support us on Patreon, you can do so at patreon.com slash cppcast. And of course you can find all that info and the show notes on the podcast website at cppcast.com
Starting point is 00:55:00 Theme music for this episode was provided by

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.