Quote of the week
Posted Dec 9, 2004 8:25 UTC (Thu) by
simlo (subscriber, #10866)
In reply to:
Quote of the week by elanthis
Parent article:
Quote of the week
In honesty, it doesn't matter - most of the truly interesting C++ stuff (i.e., the stuff beyond just syntactic sugar) really isn't a good idea to use in a kernel, and I'd rather the developers use what they're comfortable with.
I don't know what you call interesting in C++, but I can easily point out 2 places where C++ would be really nice:
1) Instead of using pointers to a struct of function pointers use virtual functions in C++. What will actually happen runtime will be the same.
2) Ingo Molnar have replaces spin-locks with muteces in his real-time patch.
Some are left as spin-locks, some are changed. But the interface is the same. So how does the kernel know which function to call when the lock has to be locked/unlocked?
This is now done by explicitly making typecheck's with if's in the code. Ugly! In C++ you just overload the function. It will all be done compile time! In general it is much easier to fix interfaces in C++ without breaking compability with existing code
- without making extra runtime checks!
C++ also has a lot stronger type-checking so you can do a lot more checking compile time.
I don't know about templates. In some way they are very elegant and I have done some really nice stuff with them. You can make the compiler do a hell of a lot of the work for you and make much more efficient code because
a lot of the logic can be done compile-time. But they are really hell to debug from outsiders and doesn't really work the same in all compilers...
(
Log in to post comments)