Re: linux headers and C++

Marco Ermini (mail@markoer.org)
Tue, 6 Jul 1999 20:57:23 +0100


----- Original Message -----
From: Horst von Brand <vonbrand@inf.utfsm.cl>
To: Marco Ermini <mail@markoer.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.rutgers.edu>
Sent: Tuesday, July 06, 1999 5:56 PM
Subject: Re: linux headers and C++

> > I understood. But of course, all that could be
> > done in C could be done in C++ too. And making a
> > new object "just like that one, but with this little
> > tweak" could also be done, and could be done much
> > more clearly in C++.
>
> If the "little tweak" means completely replacing a member function by
> another one at runtime? (Saw it somewhere, don't remember details)

This is a case in which is better
to use C-like programming. I.e., the
fact that in C++ you have STL,
which have lists, double linked lists
etc. don't means that sometimes
it's more efficient to use a char **.

In some case

mystruct** foo;

is good, in other parts you may want to use

using namespace std;
list <myclass> *foo;

Because it's more readable, you could
extend it, you could use contructor/destructor
with less caring of memory leaks etc.

Of course, if you want low level control
on the code, you may prefer the first
option, but in the long run and on
complex projects you'll feel the
benefit of the second. I just wanted
to say that I don't think it's always
good to have the same choice,
we always have to choose the best
method without prejudice.

> It's part philosophy, I'd say: The linux kernel is written in a quite
> particular OO style, the OO style suited to C++ is very different. Porting
> the kernel (all 50Mb of it!) to C++ won't just happen.

No, Linux it's not good for OOP.
I feel C is best for Linux because Linux was born
as it was, and the state of the art of Linux
needs C. OO programming needs much
more planning of pure C, and the way
the Linux kernel is developed, thru an hack
to another, and the quantity of patches posted
any day in a random way by many people (often
without trying them, ever to see if they could
compile), make me feels that C is compulsory.
If any day Molnar or Arcangeli or Cox or
everyone elses post patches on patches
without a plans, and trying them until
they founds the best way, C is compulsory.
With OOP you just can't do it, you need
planning. Linux don't come from a full featured
project, it was an hack of a swedish student
and it grows from it, from the everyday hacking
of hundreds of programmers in the world.
IMVHO this is why it definively needs C.

> The VFS is a class, each filesystem its subclass, each individual
filessytem
> on disk is an object.

In fact, this is a part of Linux don't I
know very much. I feel that device handling
is much more suited to OOP than
kernel code itself (until someone
will build an OO microprocessor ;-)

Cheers

Marco

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/