Could Linus Torvalds consider introducing C++ to the Linux Kernel?


Linus Benedict Torvalds is a software engineer, known for initiating and maintaining the development of the Linux kernel.

a few weeks agos we share here on the blog the news about a proposal which has been revived after many years in relation to the viability of adopting C++ code in the Linux kernel, a proposal that was launched in 2018 as a joke.

La proposal was launched again on the Kernel mailing lists, but in a serious way for Hans Peter Anvin, A key Intel kernel developer and developer raised the feasibility of including C++ as a third programming language in Linux.

Linux C++
Related article:
C++ on Linux, the topic is revived after 6 years

With the introduction of Rust on Linux, many developers and part of the community saw a great path ahead in Linux, plus it also Various "ideas" have emerged to implement other programming languages, the proposal to implement C++ once again opens a debate among many of the Kernel developers and even Linus Torvalds once again explains in the most passive and understandable way possible, why Linux is not prepared for C++ (sarcasm).

We must remember that Rust was not accepted in Linux from one moment to the next, since the Rust project on Linux (Rust for Linux) had a series of revisions by Linus Torvalds himself before it was accepted into the main branch of the Kernel for it to be included and it is worth mentioning that the father of Linux was nothing soft when making revisions and commenting on proposed changes.

Before developing the article, I must mention that all the content of the article is a personal opinion generated through the interpretation of the information and news that I have read on the Internet, so it may be different from the interpretation that you as a reader may have. have and that I will gladly take the time to read if you want to share it here in the comments.

Now in the case of the proposal of C++ as a third programming language, in the alleged case, and I say “of course”, The implementation should go through a similar series of reviews, if not even more rigorous than it was for Rust. And the fact of mentioning this is because C++ and Linus have their history, small, but already many years old.

The reason for mentioning that the case for C++ as a third Linux language as a “Supposedly”, it is because the father of Linux, Linus Torvalds, has not and will not view C++ favorably., since on more than one occasion at every opportunity he has mentioned that C++ "is a terrible language."

By mentionr some of the moments in which the use of C++ has been considered on Linux and Linus Torvalds has expressed not only his disagreement, but a "certain hatred" towards C++ which is overlaid to mention why "it is simply not an option for Linux", one of the most recent was during the reviews of the Rust implementation, since during a discussion on a Google post, the inclusion of C++ was mentioned as a suggestion:

"The solution here is simple: just use C++ instead of Rust"

To the Which Linus Torvalds couldn't help but laugh and his response was:

"LOL". «C++ does not solve any of the problems of C and only makes things worse, it really is a garbage language.

For people who don't like C, go for a language that actually offers you something worthwhile. Such as memory-safe and "that" languages ​​can avoid some of the pitfalls of C, or languages ​​that have internal GC "garbage collection" support and make memory management easier. "C++ solves all the wrong problems, and anyone who says 'rewrite the core in C++' is too ignorant to even know that."

Linus Torvalds has always considered C++ “waste” and considered it “useless” Well for the “C++ cannot solve the problem of the C language at all, it will only make things worse.” Torvalds believe that those who do not like the C language can look for a language that can really add value. For example, languages ​​that are memory safe and can avoid hidden dangers caused by C (such as Rust).

Compared with C++, Linus has mentioned why C is his standard choice:

“When people talk about the dangers caused by C, they also talk about part of the reason why C is so powerful: 'It allows you to efficiently implement all this low-level stuff,'” Linus mentioned. Also, although GC is good for simplifying programming in most cases, it is generally not something that can be done in low-level systems programming.

In fact, on the mailing lists it is mentioned that At some point an attempt was made to use C++ on Linux, in 1992 (more or less a year after the birth of Linux), but this remained only "an attempt", since Torvalds mention about this attempt:

It's awful. Believe me: writing kernel code in C++ is a FUCKING STUPID IDEA.

The fact is that C++ compilers are unreliable. They were even worse in 1992, but some fundamental facts have not changed:

– the whole exception handling thing in C++ is fundamentally broken. It is "especially" broken for kernels.
– any compiler or language that likes to hide things like memory allocations behind its back is simply not a good choice for a kernel.
– you can write object-oriented code (useful for file systems, etc.) in C, “without the garbage that is C++.”

Given these and many other comments, We can understand a little about why Linus Torvalds considers C++ to be a horrible language., in addition to criticizing the language for being used by «low-quality programmers, to the point where it's much, much easier to generate complete and utter garbage with it.» And it is that It seems that C++ was, at some point, a bitter taste in Torvalds' mouth., since in your criticisms it seems that I am trying to try C++, well I mention in an email that:

"C++ leads to really bad design choices. You invariably start using the "nice" language library features like STL and Boost and other complete and utter garbage, which may "help" you program, but cause:

endless amounts of pain when they don't work (and anyone who tells me that STL and especially Boost are stable and portable is so full of nonsense it's not even funny)
"inefficient abstract programming models where two years later you notice that some abstraction wasn't very efficient, but now all your code depends on all the pretty object models around it, and you can't fix it without rewriting your application."

So, returning to the title of the publication and having already understood a little the tip of the iceberg of the hatred that Linus Torvalds has towards C++, it is not necessary to investigate much since For Torvalds, Linux does not need any other language because C is enough and throughout this time C is, has been and will be the language that suits his work and Linus will continue to attack programming languages ​​that he does not like, especially C++.

And is that one of the many reasons why C++ is simply not considered for Linux, is that it allows exceptions, while Rust does not like C, since in kernel programming, it cannot be allowed An uncaught exception can disable the operating system, and you should not even think about the kernel ever failing.

Y in the "supposed" given that Torvalds came to consider C++ on linux, this could be more than a benefit the inclusion of a third or more programming languages, would become a problem, since for example with the implementation of Rust currently some problems are beginning to come to light, such as those we already mentioned in a publication about the current state of Rust on Linux.

Rust drivers on Linux
Related article:
Rust on Linux: advances, challenges and current status

Among the current challenges we mention in the article that one of them is «recruit more reviewers for the code that is being developed" in addition to The progress of the GCC-based Rust compiler has slowed down, alsoThere is very little chance that they will rewrite large portions of the kernel in Rust short term and even very low chances that they can do it without introducing all kinds of errors and especially compatibility problems.

If these problems, that are being reflected in Rust we add them in C++ or any other language that can be added in Linux, Kernel development would be greatly affected and with this at the beginning we would not be receiving a version every two months, but rather it would be the development between longer versions, more developers, more reviewers would be required and all this translates into greater effort.

Without a doubt, the approach of introducing C++ as a third programming language is far from being considered and as we already mentioned, one of the main impediments to this is Linus Torvalds himself.

Leave a Comment

Your email address will not be published. Required fields are marked with *



  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.