Rust vs C++

Why Does Linus Torvalds Not Like C++?

Linus Torvalds has criticized C++ for years, mainly over the Linux kernel. Here is what he has said, and the technical reasons behind the objections.

On this page
  1. What Torvalds has said
  2. Why the kernel avoids C++
  3. The hidden costs he objects to
  4. Why the criticism is about fit
  5. Where Rust fits in
  6. What this means if you are learning C++
  7. Bottom line

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 + b may 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.

The complete guide to rust vs c++

Rust vs C++ Performance
Read the guide

Keep exploring

Guides from other topics

All topics →

std::list in C++

std::list is the C++ standard library's doubly linked list. Learn to create one, add and remove elements, loop through it, and when to pick it over a vector.

std::list 5 min read

Tuples in C++ With std::tuple

Learn how std::tuple groups a fixed number of values of mixed types in C++. Covers creating tuples, reading them with std::get and structured bindings.

Tuples 4 min read