5 ms·
Almost everything the article says about the prospects for using C++ in an OS kernel is wrong. It is hard to understand how someone could know so many basic fa
by ncmncm 6y ago
Almost everything the article says about the prospects for using C++ in an OS kernel is wrong.
It is hard to understand how someone could know so many basic facts about the language and still be so thoroughly confused.
None of the reasons cited for not using C++ in kernel code is valid. None of the things claimed to be impossible are.
Example: RTTI. Really, RTTI is hardly ever used in good code. (I used in once in 10 years.) Despite its low use-value, nothing interferes with using it in a kernel.
Name mangling is absolutely no problem; neither would using `extern "C"`, if you wanted to.
Operator new is wholly compatible with kernel allocators.
The Standard Library does have read-write locks, although it is usually foolish to use such a lock in real code. It is trivial to wrap any synchronization primitive you like with a zero-overhead abstraction. Kernels tend to have their own anyway.
Exceptions in kernel threads would work identically the same as in user-level threads.
Static ctor sections could be run by kernel startup code as easily as they are run in regular programs. (Probably one would not bother running static dtor sections.)
I could go on and on, but enough.
This article joins others packed to the brim with out-and-out falsehoods. When you need to rally so many falsehoods to make your case, you end up making the opposite case--except where your audience is easily fooled.
- krizhanovsky 6y agoPlease read the discussion in https://www.reddit.com/r/Cplusplus/comments/jjtn5v/fast_programming_languages_c_c_rust_and_assembly/ https://www.reddit.com/r/Cplusplus/comments/jjtn5v/fast_prog... . In short, everything is doable, but before starting your project, which you're paid for, you have to grow quite a large C++ infrastructure, which double the native Linux kernel API in many ways. > Operator new is wholly compatible with kernel allocators. Please read the referenced thread. The things aren't so simple.
- ncmncm 6y agoPeople coding OS kernels don't ask for simple. They should demand powerful, but too often fail to.
- ncmncm 6y agoOK, I have read it. The Linux kernel is a large system. Things needed to work in Linux are not unusual for customizations needed for any large system, that we do routinely. If you think this is a problem, it can only be from lack of experience of large C++ systems. When people complain about the complexity of C++, it is generally because they have no experience of large systems that demand all kinds of specializations. C++ can be used in a simple way to write simple programs, and then you get to ignore all the knobs and switches. It can also be used in all varieties of specialized environments, and then you find knob and switch settings to make it work for that environment.