Re: OT: Open letter to the Linux World

From: Alexander Holler
Date: Thu Sep 04 2014 - 06:17:24 EST


Am 04.09.2014 09:54, schrieb Peter Zijlstra:
On Mon, Aug 18, 2014 at 08:15:45PM +0200, Alexander Holler wrote:

Hmm, a sane and maintainable solution would use C++ with which people don't
have to manually build lists or hashes for every structure like in the
kernel (generic programming done right). So you won't find much kernel
developers there. ;)


Troll a lot do you? ;-)

Not really.

I just hate all the stuff which is necessary in C when I e.g. want a sorted list, map or set for whatever structure I have the need for. I had fun doing so 30 years ago, when I started to learn C, but now it's just tiring.

E.g. for the dependency based initialization order with DT I would have liked it to have a list (or map or set) of strings (sorted) in order to find a driver by name (fast). In C++ it would need something < 10 lines of source and I would be able to change the sorting algorithm from list to map(hash) or similiar by changing a few lines. Doing so in C is just a pain. Not to speak about all the possible errors when implementing the stuff in C again and again. Ok, the kernel provides some macros for lists, but e.g. they can be found only in the kernel (which means many people don't know or remember how to use them) and are by far not that flexible.

While I like C++ (and quite a number of kernel people can in fact write
C++ no problem) we can have a long debate about whether the STL is in
fact 'done right' :-)

Up to now I haven't seen something really better. Of course, there are a lot of other programming languages which do make it easy to use lists, maps and similiar, but none of them is as fast and portable as C++ while still allowing to do low-level things (if necessary).

Also, I don't think init (as in PID-1) should be a large program, and
therefore writing it in C would be entirely reasonable.

It's a myth that C++ ends up in bigger code than C. At least in my experience. Especially when the latest additions to C++ are in effect (like the move-semantics in C++11 I like quiet a lot and which you get almost for free (by changing nothing) when you use the STL). Thread support is now also standardized (in C++11), quiet nice to use.

Regards,

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