Embedded Nirvana

Why only C


A very basic question. Why is the kernel programmed in C language and why not some more high level language like C++ . Also why do we code in C for embedded systems.

Well as a matter of fact there has been an attempt to code the kernel in C++ by Linus Travolds himself and here's what he has to say about it.

In fact, in Linux we did try C++ once already, back in 1992.

It sucks. Trust me - writing kernel code in C++ is a BLOODY STUPID IDEA.

The fact is, C++ compilers are not trustworthy. They were even worse in
1992, but some fundamental facts haven't changed:

 - the whole C++ exception handling thing is fundamentally broken. It's
   _especially_ broken for kernels.
 - any compiler or language that likes to hide things like memory
   allocations behind your back just isn't a good choice for a kernel.
 - you can write object-oriented code (useful for filesystems etc) in C,
   _without_ the crap that is C++.

In general, I'd say that anybody who designs his kernel modules for C++ is
 (a) looking for problems
 (b) a C++ bigot that can't see what he is writing is really just C anyway
 (c) was given an assignment in CS class to do so.

So in a nutshell unless you have been asked by a nutcase professor to do stuff in C++ only as an assignment, don't use C++ for developing low level applications for Embedded systems.

Posted by admin

Filed under: ARTICLES Comments Off
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.