kern/99979: Get Ready for Kernel Module in C++

Rick C. Petty rick-freebsd at kiwi-computer.com
Wed Jul 12 14:48:33 UTC 2006


On Wed, Jul 12, 2006 at 04:10:29PM +0200, pfgshield-freebsd at yahoo.com wrote:
> 
> C++ is the de-facto standard for OO

That is just sad.  So many other languages do a much better job of
implementing OO (Smalltalk, Java, Python, even Scheme).  While we're at
it, why not implement a bytecode interpreter for all of these languages
into the kernel?  That would be sweet..

I'm being facetious here;  OO has some merit but aside from that, there's
very little utility an additional language can provide.  Granted, it's
easier (read: lazier) to use:

	try {
		...
	}
	catch (...)
		...

than it is to do:

	error = some_fn_which_could_error();
	if (error)
		return error;
	...

While I haven't looked at kobj, I have seen some good implementations of OO
in plain C (GTK's gobject comes to mind).  I believe at least basic OO
framework is available and doesn't require a huge performance hit, as
undoubtedly a C++ solution would provide (at least from my experience).
For all C++ gives you, I believe the potential is there to do the same
things in C.

I'm all for making kernel code free of C++ reserved words (although I'd
recommend changing "new" to "new_obj", etc. instead of "_new" or similar).
This would allow C++ developers to write drivers and such.  But I don't
feel there is any benefit to commit C++ code into the "pristine" kernel
source.  Also, I thought the C++ "standard" was still being argued about
and thus is incomplete??  (I certainly know there are C-isms which don't
appear in any C++ standard as of yet)  Not to pick on the gcc/g++ folks,
but it's difficult to find a decent C++ compiler which implements all/most
of the language standard and also reliably compiles/cross-compiles on
various systems.  OTOH, gcc does an excellent job!

For this reason, BSD shouldn't bend over backwards for C++ developers any
more than it should for Python or Ruby developers.  The implied stability
and consistency of a finished language is exactly what is needed for a
stable and consistent OS (kernel).  Pick a language (let's call it "C")
that isn't likely to evolve any further.  Oh wait, we already did :-P

-- Rick C. Petty


More information about the freebsd-hackers mailing list