C++ in the Freebsd kernel?
There is a really interesting thread on the FreeBSD-Arch mailing list about supporting a subset of C++ in the kernel. Poul-Henning Kamp (PHK), a well known FreeBSD developer voiced objections early on in favor of an augmented C like language called K (link to FreeBSD wiki).
Poul-Henning Kamp’s main concerns revolved around his opinion that C++ made it very easy to write poor code, and also limiting the choice of compilers by “raising the bar significantly on any non GPLv3 we might consider”.
Ivan Voras, author of the pending (and currently alpha) FreeBSD installer: “finstall” — chimed in mentioning that perhaps PHK had: “A bit of the NIH syndrome here?”, continuing to say: “The less people know the language, the less it will be used. A one-off language (like “K”) applicable only for FreeBSD is not exactly doomed to popularity.”
Poul-Henning Kamp retorts with the following: “Not really. I’ve personally bugged Bjarne about making C++ usable or systems programming ever since 1987 or so, but to no avail.” … “So what I’ve been tinkering with, is not a new language, but a dialect enhanced to make kernel programming simpler.”
I encourage members of the community to read the entire thread so they can come to their own conclusions. The thread starts here in FreeBSD-Arch mailing list: http://lists.freebsd.org/pipermail/freebsd-arch/2007-October/006969.html
Resources:
http://netlab.ru.is/exception/LinuxCXX.shtml
http://lists.freebsd.org/pipermail/freebsd-arch/2007-October/006969.html
Filed under: BSD





C++ is absolutely unsuitable language for kernel development. It’s more slow than C. Object-oriented programming in kernel is a VERY bad idea. Main UNIX language is C, and C modules can be used from other languages without any problems. But there are lots of problems when trying to include C++ modules in programs not written in this language.
Dmitriy, how do you explain the existence of IOkit?
I kind of doubt the relative speed of C++ vs C is what makes it a bad idea, in fact on modern hardware the difference is probably negligible.
With my experience i can see that C++ applications are more stable and fast than C applications, i think that with today compilers a legend about ’slow C++’ is on ly legend.