Re: Linux kernel modules development in C++

From: Horst von Brand (vonbrand@inf.utfsm.cl)
Date: Wed Sep 27 2000 - 15:50:12 EST


Timur Tabi <ttabi@interactivesi.com> said:
> ** Reply to message from Tigran Aivazian <tigran@veritas.com> on Wed, 27 Sep
> 2000 20:10:49 +0100 (BST)

[...]

> > at the bottom of each message there is a url to lkml FAQ - have you read
> > it? It should say (I haven't read it myself but it _should_, Richard you
> > hear this? :) plainly that Linux (or any UNIX) kernel development in C++
> > is a very bad idea and explain why. Because C++ is not yet a mature
> > programming language for tasks where precise knowledge of the generated
> > code is required (and probably will never be). Think of C programming (in
> > the kernel) simply as an assembly programming but using compiler as a
> > useful shortcut generator, instead of typing tedious (and most
> > importantly, arch-dependent!) sequences of instructions. Just a way to
> > save time, and still remain in total control of what the resulting code
> > will do and precisely how it will do it.

> Why is that important? Sure, the kernel itself may need that level of
> control, but 90% of device drivers don't! As long as you have a decent
> C++ compiler (one that creates clean code, like Watcom's does), and you
> don't try to use esoteric features like exception handling, it should
> work just fine.

I'd say it is important specifically in device drivers, and less so
elsewhere ;-)

A couple of points:

- The kernel is C, mixing in C++ for no *real* good reason is just making
  it harder to work on.
- The work you do to match the kernel's object model to C++ is strictly
  wasted effort: The kernel's interfaces _do_ change, sometimes radically,
  and you'll have to keep up
- The idea of reusing code from other OSes with a very different internal
  layout will only make the point above even worse
- History shows that no kludged-on C++ code will show up in the standard
  kernel, so you loose the main advantage Linux gives you: Hundereds of
  other people that fix bugs and port forward for you

And again:

- Your driver won't be huge, most of the OO advantages won't show
- You don't have anywhere to inherit from sanely (sure, you can try to
  kludge C++ classes over VFS, or the interface to block drivers; but they
  won't be native C++ classes, so much of the benefit is lost, plus the
  effort invested in the wrappers is wasted)

-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Sep 30 2000 - 21:00:20 EST