[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: l4-ka, c++!

From: Espen Skoglund
Subject: RE: l4-ka, c++!
Date: Mon, 10 Nov 2003 21:08:26 +0100

[Volkmar Uhlig]
> There is the common misbelieve that C has performance advantages
> over C++.  However, that is mostly due to a misunderstanding by the
> programmers of mechanism in C++ which are sometimes heavyweight and
> not available in C.  C++ has many advantages over C, such as
> semi-strict type checking, operator overloads, virtual functions,
> stricter encapsulation (in objects), code re-use, and name spaces.
> Now one may say that in particular virtual functions are a bad thing
> due to the additional level of indirection, but that is short
> sighted.  Consider the virtual file system in most Unix derivates,
> or device drivers in general.  What everybody uses is a list of
> function pointers stored in a structure which are called for the
> different fs or driver functions.  That is not different to virtual
> functions in C++.  The generated code in C++ is even more efficient
> because you don't have these unnecessary checks for NULL-function
> pointers on every call since the compiler enforces correct function
> pointers at compile time.  (Linux even introduced constructors and
> destructors in certain places.)  That said it is of course still
> possible to write inherently inefficient code using C++, but that is
> true for almost all programming language--including C.

To summarize: To claim that C++ itself introduces inefficiencies in OS
code is complete and utter bull.  The arcane belief that C++ is too
high-level and bad-for-you is a load of FUD spread by people who do
not understand the tools or languages they are using.

Anyhow, believe it or not, I didn't really post this reply to bring
out the flame-thrower on C++ (or high-level programming language)
bashers.  I just wanted to mention another example where OO techniques
are finding their way into kernel development: The kobj(9) kernel
object system in FreeBSD is used to implement an object oriented C
programming model within the kernel [1].  Using kobj, it is even
possible to add or remove operations to/from interfaces during
runtime.  The kobj system is used pretty extensively in FreeBSD
(drivers, busses, clocks, etc.) and I don't see anyone claiming that
these OO techniques hamper the performance of the system.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]