Is there some lore about this I don’t know?
There is no C++ allowed in the Linux kernel and Linus has gone on several major rants about how terrible a language it is.
There’s assembly and makefiles too
Less of a joke answer, there has been work to allow Rust bindings for drivers.
According to the github analysis, the kernel repository is:
- C 98.3%
- Assembly 0.7%
- Shell 0.4%
- Makefile 0.2%
- Python 0.2%
- Perl 0.1%
- Other 0.1%
So yeah, its basically all C, plus a tiny bit of assembly for very low level bootstrapping and some helper scripts.
Lots of core UNIX and Linux projects are. C++ is not liked by a lot of low level FOSS community. I think Rust is going to get further into these areas. I know C++ well but prefer C. I know plenty of others who feel the same.
Then why does he write C++?
https://github.com/subsurface/subsurface/commit/1b16d570a1b6700295153bd6597b148b65000458
Torvalds just really dislikes C++. He’s gone on the record saying that he thinks it’s just not a good language. In his own words “C++ is just a waste, there is no design at all, just adding some scum on top of C.”
In the specific use case of kernel programming, maybe. But the Standard Template Library is awesome.
I would have agreed with that before C++11. But since then, C++ has improved a lot. Its like the vision of what C++ suddenly became more clear. So I wonder if Linus would still say that today. (Unfortunately, there have been a lot of missteps in the development of C++ though, and so there is a lot of cruft that everyone wishes was not there…)
”C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point where it’s much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C.”
I don’t know about Linus, but the last time Reiser’s wife was seen, she was writing a c++ hello world
”C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point where it’s much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C.”
Literally apply that train of thought to JavaScript and JavaScript is in an even worse position than C++
For an example from the other poster’s explanation:
https://lwn.net/Articles/249460/
This was pre c++11 - not sure if he’s changed his mind at all with more modern c++
That’s my guess, but there was a conversation on the mailing list a few months ago that wasn’t just immediately shut down, even by other prolific developers
Ts’o seems skeptical, but is at least asking whether c++ has improved
https://lore.kernel.org/lkml/20240110175755.GC1006537@mit.edu/
I don’t think its the ergonomics of the language he has an issue with. If anything C++1x probably just made the original critiques of bloat worse.
In that post, his critiques were around the problems with the STL and everyone using Boost. The STL has improved significantly since then, and it would be a limited subset of c++ if it was ever allowed
There have been mailing list conversations earlier this year, citing that clang/gcc now allowing c++ in their own code might mean they’ve taken care of the issues that made it unusable for kernel code
https://lore.kernel.org/lkml/e5949a27-999d-4b6e-8c49-3dbed32a00bc@zytor.com/
I’m not saying it will happen, but it’s not being shot down as an absolute insanity anymore, and I wouldn’t have expected Rust to be allowed in the kernel, either