Rust uses a different (often, in my opinion, gratuitously so) syntax
Announcement
Collapse
No announcement yet.
A 2024 Discussion Whether To Convert The Linux Kernel From C To Modern C++
Collapse
X
-
Originally posted by spicfoo View PostWhile rest of the world moved on from C, Linux ecosystem has been continuing to write even net new projects in it. This is finally shifting in the last few years where there is a strong appetite to move towards something else. Typically that is Rust or C++ (and sometimes even things like Go where having a garbage collector isn't a blocker). Either could be a step up from C and it's good to see developers evaluating both even within the Linux kernel.
Actually I have now the feeling that many of this C programmers flog to Rust. They are still cool but can now use a modern language.
- Likes 2
Comment
-
GCC is written in C, Clang/LLVM is written in C++. Look how that turned out... It took years of work, but it was not a bad idea. The hardest part is to get everyone on board, and not everyone who is good at C is also good at C++. I very much doubt it will be Torvalds who heads this and it will not happen in this decade.
- Likes 3
Comment
-
Originally posted by sdack View PostGCC is written in C, Clang/LLVM is written in C++. Look how that turned out... It took years of work, but it was not a bad idea. The hardest part is to get everyone on board, and not everyone who is good at C is also good at C++. I very much doubt it will be Torvalds who heads this and it will not happen in this decade.
- Likes 13
Comment
-
Originally posted by patrick1946 View Post
I think that C was quite often a quite strange choice for stuff like systemd etc..
Actually I have now the feeling that many of this C programmers flog to Rust. They are still cool but can now use a modern language.
- Likes 5
Comment
-
Originally posted by johanb View PostAs a C programmer that the past two years has had to learn a lot of Rust and C++ on a deeper level, while both are pretty clean when you start learning it, both become much more complicated than C when looking at real world use of it. Rust is more complicated than C, but C++ is on a whole other level due to it having an insane amount of ways to do the same thing. We have now ended up writing most of our code in either C or Rust, with bindings between them where necessary.
- Likes 6
Comment
-
Originally posted by yoshi314 View Post
that is also the problem with c++, it's an ever-evolving language. you can really write obtuse complicated meta-spaghetti code with it, with what it already has to offer. ( and i only know templating and oop, i bet there is plenty more)
Originally posted by yoshi314 View Post
That and i think debugging might require a bunch of new tools. I've heard some programmers say that assembly is easy to trace back to specific line in C code. with C++, things may get more tricky.
There is also an issue of potential lack of compiler for a given new platform or issues porting/backporting patches as c++ standards will shift across kernel versions. it's so much faster/easier to provide a C compiler than a C++ one. but maybe with modern tools it's not so bad.
Now, the tools are the same, there is actually 0 difference in compiler and tool support between C and C++.
Ironically, bleeding edge c++ still can't do some of the stuff trusty old macros have been doing forever.
There is nothing you can do with C preprocessor that can't be done with C++ template. Even reflection is kind of coming to C++.
However, the work to convert the linux code base to C++ is just too huge for it to happen, even if it would become a lot smaller, safer and easier to maintain.
- Likes 10
Comment
-
I prefer Rust in terms of cleaner code. You don't have automatic garbage collection tools in C++ and this can contribute to more runtime errors. With Rust's tools you can see when something is wrong due to compilation errors. So the proposal for C++ is missing on the human factor and this is introducing more manual errors, which can hardly be afforded in a kernel with a growing complexity. Fact is C++ requires more time and care unlike rust. Rust is also extremely helpful when reverse engineering by the way.
- Likes 6
Comment
Comment