5 ms·
A 2024 Discussion Whether to Convert the Linux Kernel from C to Modern C++
- karmakaze 3y agoI don't normally get into C/C++ or kernel chats, but I hope they choose something different than C++, maybe Zig. The problem with C++ is that like Scala, it's hard to stick to a subset without realizing you've used more than intended after the fact. Maybe the kernel team could do it since there's a culture of keeping things clean/simple.
- kreetx 3y agoI think they'll likely agree on some C++ subset when getting into it so I wouldn't be worried. Though, why not just evolve C itself with those features? C is evolving, too, and this could be used as a vehicle for it.
- teleforce 3y agoPerhaps they should just jump straight to D. The proposed C++ 20 is like D-- given how many D features have been adopted over the years. Now that D supports C native compilation and supported by GCC eco-system so the conversion can be done in peacemeal, it will be win-win situation for safety, convenience, power and flexibility. One of the main reasons of switching to C++ given is for templates, and D templating system is second to none. D also run and compile as fast as C, and the latter cannot be said to C++. For kernel developers fast compilation will be necessary not a luxury. Imagine kernel development in D without GC and user level development with D with the default GC, it really looks like a match made in heaven to me.
- jerf 3y agoModern C++ has addressed none of the reasons Linus originally rejected it. Those reasons were widely misunderstood, but I tried to explain them at the time and it seems to have helped at least some people: https://news.ycombinator.com/item?id=1422160 https://news.ycombinator.com/item?id=1422160 Given the original objections, it should only be even more objectionable now as C++ has added even more subtleties and even more you have to understand in order to fully grok what a given bit of C++ code is doing. I'd also disagree with the idea that it's lower effort to add C++ than to use Rust. C and C++ have diverged wildly. Knowing C means you can mostly write C (and that only mostly) in C++ but it does not mean you know C++ anymore. Maybe literally 30 years ago you could show a C programmer how C++ compiles down into C and that would be enough for the C programmer to start bashing away at C++, but that day is long past. In terms of whether it is easier to ask a kernel developer to learn Rust or to learn C++, bearing in mind a kernel developer would be pretty much required to learn all of C++, every last quirk and every last detail, it honestly could still be advantage Rust on that front. Katamari Dama-C++ is a monster.
- bryanlarsen 3y agoThey're talking about a very small strict subset of C++. For example, it excludes function and operator overloading, so your 2010 comment is handled.
- pointlessone 3y agoI’m not familiar with C++ so might be a silly question but is it possible/easy to enforce usage of an arbitrary subset of the language features?
- bryanlarsen 3y agoEasy? No. But the Linux kernel is one of the places where it is definitely possible. Kernel patches are well reviewed both manually and automatically.
- hulitu 3y ago> A 2024 Discussion Whether to Convert the Linux Kernel from C to Modern C++ They can call it Windows then. /s