Re: linux headers and C++

Horst von Brand (vonbrand@inf.utfsm.cl)
Tue, 06 Jul 1999 08:59:13 -0400


"Marco Ermini" <mail@markoer.org> said:
> Alan Cox <alan@lxorguk.ukuu.org.uk> said:

> > Please don't confuse object oriented with C++. Decent programmers can
> > write object oriented assembler, fortran or even cobol (although they
> > normally leave in the latter case). Linux is heavily object oriented
> > but without using a glorified pre-processor on it

> I don't feel Linux is *so* object oriented.

Look at the way files, filesystems and devices are handled: All structs
full of function pointers to say how the jobs are supposed to be done. That
is objects with virtual functions done in C. Also note that in some places
the kernel does things that are impossible (or close) in C++: Switch around
the virtual functions, do a new object "just like that one, but with this
little tweak", ...

Object orientation was born in the Unix kernels (at least one of the
strands was); Linux relies on that tradidion, and expands it.

> Apart from this C++ is no more just a
> pre-processor. Of course a C and ASM
> hacker could feel in this way, but it's not
> true; C++ could be used as an improved-C
> or as a full-featured OO-language. Using
> C or ASM or another language in an OO
> way without a specific support for this could
> lead to more complications that it's worth (i.e.
> you could program as you have inheritance
> without having a keyword to do it, but it's
> very difficoult to keep the code clean).

The kernel shows how it is done. No keywords needed. Some readers of the
source aren't even aware of what is going on. What more transparency you
want? ;-)

> Looking at the Linux source tree, I don't
> think Linux is OO. But I personally
> don't feel it as a limitation per se. WinNT
> is (maybe?) OO. What's the result? The
> only things that count, at the end, are the
> results. Linux could be not OO, but the
> sources are (quite) always clean and
> understandable.

That is hard to achieve whatever the language, and IMVHO one of Linus'
greatest achievements

-- 
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.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/