Linus Torvalds, who created Linux, has been openly critical of C++ for many years. His objections focus on operating system work, where he argues that C++ features hide costs and add complexity. The Linux kernel is written in C, and the reasons go beyond personal taste. This article covers what he has said, the technical concerns behind it, and what the criticism does and does not mean.
What Torvalds has said
In a 2007 mailing list message, Torvalds called C++ “a horrible language.” He argued that the language is made worse by programmers who use it without the skill to avoid its pitfalls. The remark came from a technical discussion, not a formal policy statement, and he has voiced similar views in other settings over the years.
Why the kernel avoids C++
The kernel runs in a special environment, and several C++ features do not suit it:
- No standard library. Kernel code cannot rely on the C++ standard library, which assumes an ordinary user-space program.
- No exceptions. Exception handling needs runtime support that the kernel does not provide.
- Predictable memory and time. Constructors, destructors, operator overloading and implicit conversions can run code that is not obvious from the line that triggers it.
- Stable binary interfaces. C has a simple, stable calling convention. C++ name mangling and differences between compilers complicate the boundaries between the kernel and its modules.
The hidden costs he objects to
The objections, as they are usually summarized, come down to a few features:
- Overloaded operators.
a + bmay run a function that allocates memory. The code looks cheap, but it might not be. - Implicit constructors and destructors. Objects can run code at the end of a scope without any visible call.
- Templates. Templates are powerful, but they can expand into large amounts of code and produce error messages that are hard to read.
- Exceptions. Exception handling adds control flow that can be hard to follow in low-level code.
These are real trade-offs. In application code, many programmers accept them in exchange for expressiveness and safety.
Why the criticism is about fit
The criticism is about kernel work and low-level design, not a verdict on C++ as a whole. C++ is widely used in games, browsers, financial systems, embedded work and scientific software, where its features suit the job. Many experienced C++ developers disagree with his view. The language has also changed a lot since 2007, and newer standards such as C++20 added concepts, ranges and modules.
Some readers ask “Is C++ basically C with classes?” The original idea behind C++ was close to that: Bjarne Stroustrup began by adding classes to C. Modern C++ has grown well beyond that starting point, and much of the friction between kernel developers and C++ comes from that growth.
Where Rust fits in
Rust support has been part of the mainline Linux kernel since version 6.1, released in late 2022. Torvalds has been supportive of Rust for kernel code, particularly drivers, as long as it fits alongside the existing C code. Rust brings different trade-offs. Its compiler checks memory safety at build time, which addresses a different set of concerns from the ones Torvalds raised about C++.
What this means if you are learning C++
- Learn the core features well, so you can judge when a feature helps and when it hides a cost.
- Read low-level C++ code, such as embedded or systems projects, and compare it with C code written for the same job.
- Treat the criticism as a set of trade-offs to weigh, not a rule to follow. C++ remains widely used, and its features are designed to be used with care.
Bottom line
Torvalds’ criticism of C++ is about kernel work, and about the hidden costs and complexity of some C++ features. It is a specific view rather than a general judgment about the language. Understanding his reasons is useful for any C++ programmer who wants to think about cost, control and maintainability.