lkml.org 
[lkml]   [1999]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: linux headers and C++
Date
----- 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 1:59 PM
Subject: Re: linux headers and C++


> "Marco Ermini" <mail@markoer.org> said:
> [snip]
> > 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.

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++.

Using a struct with function pointers instead
of classes inheritance and polymorphism
just means using an older techinque; with
C++ you could just do it in a cleaner way.
Maybe you could have the sensation to lose
the low-level control on the code, but you
gain in clearity and simplicity in the manteinance
of the code. This could lead you in being more
productive and effective in adding new features
and objects, and being less error-prone doing it.

Of course, there are many reasons that could
lead to prefer C over C++. If your C++
compiler is not so good, if you want to be
sure to have an optimal control on the
generated code and you don't know the C++
compiler so good as the C one, etc. But
are you sure that you are preferring C over
C++ just because you don't feel confortable
with C++? it's a clear and motivated decision
or just a commodity? it's "better" per se' or it
just fits better because the "history" of the way
Linux was born?

> > 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? ;-)

In fact, I can't see something reminding
me of inheritance in the "kernel" itself, and
I don't see how we may need it (not
speaking of devices handling, for example,
or files and inode etc., just the processes
handling per se).

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

I agree, and that's what I mainly
admire in Linus and Linux.

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/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.093 / U:0.568 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site