Re: C++ in kernel (was Re: exception in a device driver)

Thomas Pornin (pornin@bolet.ens.fr)
Tue, 12 Jan 1999 11:40:43 +0100


On Tue, Jan 12, 1999 at 10:49:39AM +0100, Marc Espie wrote:
> C++ template expansions can do the exact same things C macros do, with
> strict type-checking, and with smarter behavior, since you can change
> the code emitted depending on the type of the object.

Actually that is not what you want. You do not want to unroll loops
depending on the object type, but on a case-per-case basis. Depending on
where it is used and on tricky hardware-related issues.

Otherwise, type-checking might be good, but not worth the effort in my
opinion; I think a separate type-checking tool would be better: C++
gives it, but not alone. Same philosophy as the usual micro-kernel
flame: you want portability, micro-kernel gives it, but you do not want
all that comes with it; therefore the Right Way is to get portability
with other means. Here you want a type-checker. Using C++ just for this
is like hammering a mosquito: yes it works, but maybe you do not want
the extra features (think that mosquito land on your face sometimes).

Too bad Dom did not pursued his great project.

> Hence, having even a tiny little bit of linux drivers written in
> C++ would be a huge gain for the C++ community.

Then just do it. It would require little work with the headers. This would
lead mainly to three possible situations:
-- The new driver is good and people use it; the C++ feeadback helps
in improving egcs and eveything is good. Probability 20%.
-- The new driver sucks. The egcs people lynch you, and Linux is in C
forever. Probability 10%.
-- The new driver is good, people want to use it, but the extra work of
getting new versions of the C++ compiler gets on their nerves. Finally,
someone exhibits a just as good driver, in plain C. Another proof that
the coding language is less important than the ability to gather
free code reviewers, nothing more. C++ for Linux remains an open
question, just delayed one or two more years. Probability 70%.

If the kernel had been written from the very beginning in a full-object
C++-tied manner, then every kernel developper would be using C++. But
Linus prefered C. So be it. See BeOS for a C++ kernel. Too bad it is not
Open Source.

(The main idea is: there is only one way to convince people: produce code,
prove by reproducible facts)

--Thomas Pornin

-
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/