On Wednesday 09 November 2005 10:29 am, Kai Ponte wrote:
Allen,
Umm.. How do you get that? It is rather the other way around. C++ apps are generally slower. Why is the Linux kernel written in C? If C++ was faster, then would that not have made sense?
Actually, either can be faster/slower than the other, depending on the optimization used and other relevant factors.
The places where C++ code can be faster are not relevant to a lot of applications. They mostly apply to number crunching and chains of mathematical expressions. If I get motivated, I may try to fish out an example. As for why the kernel is written in C++. 1) Linus doesn't know how to use C++ correctly 2) C++ was not mature when the linux project was started 3) There's a certain amount of chicken and egg problem in that C++ relies on functionality provided by the kernel. Of course all that is done in C within the kernel could be done with C++. The differences between ANSI C and the C subset of C++ are trivial. This may be of interest: http://netlab.ru.is/exception/LinuxCXX.shtml Steven