l4-hurd
[Top][All Lists]
Advanced

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

RE: l4-ka, c++!


From: Volkmar Uhlig
Subject: RE: l4-ka, c++!
Date: Mon, 10 Nov 2003 06:57:44 +0100

> -----Original Message-----
> From: swin [mailto:address@hidden 
> Sent: Sunday, November 09, 2003 3:47 PM
> To: Max Laier
> Cc: l4-hurd
> Subject: Re: Re: l4-ka, c++!
> 
>    But do you think with the using of C++, it can make
> the object file or executable file bigger while comparing 
> with c. Is l4-ka so?

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.

When we designed L4Ka::Pistachio the main focus was on performance and
we would not have chosen C++ if that would give us any performance
disadvantage.  Usually, structural problems are of greater concern here,
and that is true for almost all projects.  Consider MACH--even though it
was written in C, performance was terrible.

It would be great to see a shift away from C towards better programming
languages in general considering all these unnecessary bugs in OSs we
see every day.  And I'm not talking about C++ here...

- Volkmar




reply via email to

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