C++:Systems
From a 1979 Bell Labs side project to "add classes to C" — to the king of performance behind every OS, browser, game engine, and database. 46 years on, it is PyTorch / TensorFlow's actual compute, the engine of Chrome / V8, the chassis of Unreal Engine 5 / Photoshop / Office. The hotter AI gets, the more it is needed.
Bell Labs · Bjarne Stroustrup
Python is just skin
Chrome / Unreal / V8 / Office
reflection / profiles / patterns
What is C++
C++ is a multi-paradigm systems language: procedural / object-oriented / generic / functional — all supported, all bound by one creed: "zero-overhead abstraction". Unlike Python, it doesn't optimize for "developer joy"; unlike Rust, it doesn't try to "stop you compiling bad code". It optimizes for "express anything, with no runtime cost".
Procedural / OOP / generic / functional / metaprogramming, all in one pot. The same code can be a C-style for loop or a ranges-style pipeline.
What you don't use, you don't pay for. What you do, you couldn't hand-code any faster. Templates, lambdas, smart pointers vanish at compile time — runtime equals bare metal.
Pointers, memory layout, SIMD intrinsics, inline assembly — all yours. alignas for cache lines, volatile for direct MMIO.
Every C library is callable, no glue required. This is why every "native module" in Python / Node / Ruby — and every OS syscall interface — is essentially C++'s next-door neighbor.
// Old-school C++98 — manual everything
std::vector<int>* v = new std::vector<int>();
for (std::vector<int>::iterator it
= v->begin(); it != v->end(); ++it) {
std::cout << *it << " ";
}
delete v; // 忘了 = leak// Modern C++ — feels almost Pythonic
auto v = std::vector{ 3, 1, 4, 1, 5 };
std::ranges::sort(v);
for (auto x : v) {
std::print("{} ", x);
}
// RAII 自动清理
// 没有 new / deleteHistory : Timeline
From a Bell Labs PhD student wanting Simula's class system in C, to holding up most of the software world 46 years later — C++ wasn't built overnight. It's the slow, deliberate work of an ISO committee decade after decade.
- 1979
"C with Classes" begins
At Bell Labs, Bjarne Stroustrup, inspired by Simula 67's class system from his PhD work, decided to bolt classes onto C. The first name was "C with Classes". Stroustrup wanted Simula's expressiveness with C's runtime speed — the "zero-overhead abstraction" creed was born here.
- 1983
Renamed to C++
Rick Mascitti, a colleague, suggested the name — taking C's increment operator
++as a play on "one step beyond C". The first edition of The C++ Programming Language shipped in 1985, kicking off the de-facto standard era. - 1998·09
C++98 — the first ISO standard
September 1st: ISO/IEC 14882:1998 ratified. The STL — containers / algorithms / iterators, by Alexander Stepanov — became part of the standard. C++ stopped being "whatever AT&T says".
- 2003
C++03 — defect report
Mostly a bug-fix release for C++98, no new features, but it pinned down the wording where vendors disagreed most. Then C++ went quiet for nearly a decade — until C++11 changed everything.
- 2011
C++11 — the modern era begins
A wholesale reinvention.
autodeduction, lambdas, rvalue references and move semantics,std::unique_ptr/shared_ptrsmart pointers, range-based for,nullptr,std::thread, variadic templates… Stroustrup's own words: "It feels like a new language." - 2014
C++14 — polishing C++11
Generic lambdas,
autoreturn-type deduction, variable templates,std::make_unique. A point release on top of C++11, but the code finally flowed naturally. - 2017
C++17 — pragmatic engineering
Structured bindings
auto [a, b] = pair,std::optional/variant/any, parallel algorithmsstd::execution::par,if constexpr, the filesystem library. For the first time, day-to-day C++ code felt close to Python or Rust ergonomics. - 2020
C++20 — the big four
Concepts (generic constraints), Modules (replacing
#include), Ranges (pipeline-style collections), Coroutines. These four reshape what C++ looks like — template errors go from 30-line incantations to a single sentence, and modules open the door to fundamentally faster builds. - 2023
C++23 — consolidating C++20
std::expected(Rust-styleResulterror handling),std::print(Python-flavored formatted output),std::mdspan(multi-dimensional array views for scientific code),std::generatorcoroutine-backed iterators. Modules finally stabilizing in the wild. - 2024
The White House nudge + the Profiles answer
February 2024: the White House ONCD recommends replacing C / C++ with memory-safe languages like Rust or Swift. Stroustrup and Herb Sutter respond with C++ Profiles — opt-in compiler-enforced safety subsets (bounds / lifetime / null checks) that don't break existing code. The NSA memory-safety report puts C++ in the "unsafe" column the same year.
- 2025
TIOBE top 3 + Google's Rust data
TIOBE 2025 ranking: Python · C++ · C round out the top three (Java drops out). Google publishes the data: after switching new Android code to Rust, memory-related bugs fell 50%+. Yet C++ retains its grip on AI / HPC / games / high-frequency trading — Rust is mainly winning new systems projects, not displacing the existing ones.
- 2026
C++26 in flight
Static reflection (compile-time introspection), contracts,
std::executionconcurrency model, pattern matching. From Stroustrup's CppCon 2025 keynote: "C++ is 46 years old, and it's still writing the most challenging code in the world."
Language Essentials : TheCoreEight
The C++ surface is huge — two 1,500-page books can't cover it. But 80% of modern code uses just these eight primitives. Master them and you can read most of PyTorch / Chrome / Unreal source.
Classes & RAII
"Resource acquisition is initialization" — destructors clean up at scope exit. No GC, no try / finally, just structured lifetimes.
class File {
FILE* f;
public:
File(const char* p)
: f(fopen(p, "r")) {}
~File() { fclose(f); }
};
// 离开作用域 fclose 自动调用Templates & generics
Compile-time code generation. One source, every type, zero runtime cost — unlike Java's type erasure.
template <typename T>
T max(T a, T b) {
return a > b ? a : b;
}
max(3, 7); // T = int
max(3.14, 2.71); // T = doubleSmart pointers
Stop writing raw new / delete. unique_ptr for sole ownership, shared_ptr for shared, weak_ptr for non-owning — ownership becomes part of the type.
auto p =
std::make_unique<User>("Bjarne");
// 离开作用域自动 delete
// 不能拷贝, 只能 std::move
auto q = std::move(p);
// p 现在是 nullptrMove semantics
Rvalue references && make "transfer ownership" expressible — orders of magnitude faster than copying, avoiding allocations entirely.
std::vector<int> a = { 1, 2, 3 };
std::vector<int> b = std::move(a);
// b 接管底层数组
// a 变成空, 但合法
// 没有拷贝百万元素Lambdas
Anonymous functions, since C++11. The capture list [&] / [=] chooses by-reference vs by-value capture; the compiler emits an anonymous functor.
int cutoff = 10;
auto small = [cutoff](int x) {
return x < cutoff;
};
std::ranges::filter(v, small);STL containers & algorithms
Stepanov's "containers / algorithms / iterators" trio. vector / map / unordered_map coupled with sort / find / transform, glued together by iterators.
std::vector<int> v = { 3, 1, 4, 1, 5 };
std::sort(v.begin(), v.end());
// C++20 ranges 风格
std::ranges::sort(v);
auto it = std::ranges::find(v, 4);Inheritance + virtual functions
C++ is one of few mainstream languages that allows multiple inheritance. Runtime polymorphism via virtual functions and a vtable; compile-time polymorphism via templates. Both paths, side by side.
class Shape {
public:
virtual double area() const = 0;
virtual ~Shape() = default;
};
class Circle : public Shape {
double area() const override;
};constexpr / concepts
The eighth: compile-time computation + concept constraints. constexpr evaluates Fibonacci at compile time; concept turns 30-line template errors into one-line plain English. Since C++20, these two killed the "templates = black magic" reputation.
"Give a language type-level computation, and it stops being a language — it becomes a meta-language toolkit."
Why C++ : WhyCpp
Not every project should use C++. But when "performance is justice" — OS kernels, browsers, AI cores, game physics, HFT — it remains irreplaceable.
Zero-overhead abstraction
Stroustrup's law: "What you don't use, you don't pay for. What you do use, you couldn't hand-code any faster." Templates, lambdas, smart pointers — abstractions vanish at compile time; runtime equals bare metal.
auto f = [](..){...};
// inline 后等同手写 CSpeaks directly to hardware
Pointers, memory layout, SIMD intrinsics, inline assembly — C++ gives you control "down to the cache line." That's why OS kernels, compilers, and database engines are all written in C++.
alignas(64) int buf[1024];
// 对齐到 cache lineRAII = safety without GC
Constructors and destructors pair up, cleanup happens at scope exit. 80% of leaks just disappear; the remaining 20% are handled by smart pointers and RAII wrappers like std::unique_lock.
{
std::lock_guard lk(m);
// ... critical
} // 自动 unlockSTL — battle-tested collections
40 years of polish. std::sort is introsort (quicksort with heapsort fallback); unordered_map picks open addressing or chaining per implementation. Each container's complexity is guaranteed in writing by the standard.
std::ranges::sort(v);
// O(n log n), 标准担保Cross-platform since day one
Linux / Windows / macOS / iOS / Android / embedded / WebAssembly — wherever a C compiler exists, C++ follows. GCC, Clang, and MSVC track the ISO standard in lockstep.
// 同一份源码
// gcc / clang / msvc
// 全部能编Performance as a virtue
HFT needs nanoseconds, game engines need 60fps physics, AI inference needs every GPU cycle — these scenarios are C / C++ only. Python / Rust / Go all run on top of C++-written runtimes.
// HFT 报单 < 500ns
// PyTorch tensor op
// V8 JIT compileComputed at compile time
constexpr / consteval / concept let you compute Fibonacci, parse SQL, or do type inference all at compile time. The runtime only "moves the result out" — a feature Rust and Zig are still chasing.
constexpr int fact(int n)
{ return n ? n*fact(n-1) : 1; }
// fact(10) 编译期算完Unmatched ecosystem depth
Forty years of libraries: Boost / Eigen / OpenCV / Qt / Unreal / TBB / GoogleTest — plus the entire C ecosystem callable without friction. Things other languages "bind to", C++ owns natively.
// Eigen, OpenCV,
// CUDA, MPI, Qt
// 全部 first-partyThe AI era = the C++ era
PyTorch / TensorFlow / JAX look like Python, but the actual tensor math runs in C++ kernels. CUDA kernels, libtorch, XLA, ONNX runtime — the more AI booms, the more C++ is needed.
// torch._C → libtorch.so
// XLA → C++ + LLVM IR
// CUDA kernel = C++Who's Using : ProductionUsers
Every browser tab, every PyTorch run, every Unreal game session, every Photoshop edit — what's actually computing is C++. The 12 projects below set the global floor on software performance.
C++ in the : AI Era
The 2020s gave us a delicious paradox: people said AI would obsolete "low-level languages". The reverse happened — the hotter AI gets, the harder the bottom is squeezed for performance, the more C++ is needed. This chapter is why PyTorch / TensorFlow / JAX look like Python but are bone-deep C++.
"People think the more high-level languages there are, the less C++ is used — actually the opposite is true. The hotter Python / JS / Julia get, the deeper their dependence on native libraries. PyTorch, TensorFlow, NumPy, V8, Node, Chrome — the real compute behind all these "high-level abstractions" is C++. We're not retreating, we're becoming infrastructure.
You type torch.matmul in Jupyter — one Python line. Underneath, torch._C hops straight into libtorch.so, a C++-compiled shared object. One layer below, CUDA kernels — still C++-flavored syntax. Python is barely 1% of the call path.
Chrome ~32M lines, Unreal Engine ~2M, Office ~50M, Photoshop ~15M — at least 5 billion lines of C++ in production worldwide. Any "switch the language" proposal has to confront that number first.
TIOBE 2025: Python · C++ · C take the top three; Java drops out. GitHub data: C++ repo growth holds in the leaderboard; the new-project share is actually higher than in the 2010s. Looks like a "legacy language", actually still growing.
PyTorch
People think PyTorch is a Python library — wrong. PyTorch's actual body is libtorch, roughly 2M lines of C++ + CUDA. The Python layer is the steering wheel for researchers — convenient, but not the engine.
- ATen — Tensor op library — pure C++ templates
- c10 — Core data structures (Tensor / Storage / Device)
- CUDA kernels — GPU compute — C++ subset + nvcc
- JIT (TorchScript) — C++-written IR + compiler
The 700+ H100s training ChatGPT, every frame Sora renders, every LLaMA fine-tune on your laptop — at the bottom, this C++ code is running.
// PyTorch's C++ core, roughly
template <typename scalar_t>
void matmul_cuda_kernel(
const scalar_t* A,
const scalar_t* B,
scalar_t* C,
int M, int N, int K) {
// CUDA threads compute one tile
// using shared memory + tensor cores
// ...
}
// What Python's torch.matmul
// actually dispatches toAI infrastructure · almost all C++
More high-level langs ↔ more C++ needed
When Python / Ruby / JS took off in the 2010s, outsiders guessed C++ would die. The reverse happened: every high-level language needed a "C++-written native backend" to run fast.
Python's NumPy / Pandas / SciPy — C / C++ kernels. Node's V8 — C++. Ruby's YJIT — C. Julia's LLVM JIT — C++. React Native's bridge — C++/Java/Swift. Every layer of "fast" is C++.
So Stroustrup's response has always been calm: "We're not competing with Rust / Python — we're their chassis." The AI boom only thickens that chassis.
// What you write in Python:
model = torch.nn.Linear(512, 10)
y = model(x)
// What actually runs:
// torch.nn.Linear → torch._C →
// libtorch.so::Linear::forward (C++)
// → ATen::mm (C++ template)
// → cuBLAS::gemm (CUDA / C++)
// → tensor cores (硅片)
// Python: 1 line.
// C++ + CUDA: everything else.Summary, one line: AI doesn't retire C++ — AI turns C++ into deeper infrastructure. The bigger Python's dashboard, the more critical the C++ engine below. Stroustrup's creed of "zero-overhead abstraction" — in an era where every femtosecond of GPU time is counted — is worth more than it was in 1979.
vs Rust / C : ThreeWayCompare
Three systems languages on the same field. Rust stops you at compile time; C makes you fully accountable; C++ gives you safety tools but doesn't enforce them. Each owns its territory.
| C | C++ | Rust | |
|---|---|---|---|
| Year | 1972 | 1979 | 2010 |
| Memory safety | None, on the dev | RAII + smart ptr cuts most | Compile-time borrow checker |
| Abstraction | Structs + pointers | OOP + templates + lambda + concept | traits + generics + enums |
| Compile-time eval | Macros (ugly) | constexpr / consteval | const fn (limited) |
| Generics | None (macros barely) | Templates (Turing-complete) | Trait-bounded generics |
| Ecosystem | 50 yrs, systems | 40 yrs, full-stack giant | 15 yrs, growing fast |
| Compile speed | Very fast | Slow (templates/headers) | Slow (trait checks) |
| Runtime perf | Bare metal | Bare metal (zero-overhead) | Bare metal (on par with C/C++) |
| Concurrency | pthread | std::thread / std::execution | async/await + Send/Sync |
| Home turf | OS kernels / embedded | AI / games / browsers / HFT | New systems / crypto / web backends |
| Legacy LOC | Tens of billions of lines | 5B+ lines | Tens of millions, growing |
| Learning curve | Small grammar, many traps | Sprawling features, factional styles | Steep borrow-checker wall |
Outlook : TheRoadAhead
The 2024 White House nudge "use safer languages" made outsiders think C++ was exiting. But the ISO committee accelerated Profiles that same year, and AI pushed C++ deeper into infrastructure — the next decade is busier than it looks.
C++ Profiles — the safety counter
February 2024: the White House ONCD report names C / C++ as "memory-unsafe". Stroustrup and Herb Sutter team up on Profiles — opt-in compiler-enforced safety subsets (bounds / lifetime / null) that don't break existing code. Targeting C++26 / C++29.
Stroustrup's own words: "We don't need to rewrite the world's 5 billion lines of C++. We need to make old code safe."
Static reflection lands
After more than a decade of proposals, compile-time reflection finally enters C++26. Walk class members at compile time, auto-generate serialization, do ORM — no more macro black magic or external codegen.
AI kernels are 100% C++
PyTorch / TensorFlow / JAX / vLLM / llama.cpp — Python is the dashboard; the actual math is C++ + CUDA. The more pervasive AI gets, the more C++ is needed below. "More high-level languages above, deeper the C++ moat."
Coexisting with Rust
Google: Android's new Rust code cut memory bugs 50%+. But 5 billion lines of legacy C++ aren't going anywhere. Stroustrup's take: "Rust is a fine language, but C++ remains the home field in AI / games / HFT." Dual tracks are the next 20 years' reality.
Modules finally usable
The C++20 module system (replacing #include) is finally well-supported across MSVC / GCC / Clang in 2025. Build speed-ups in the 5×–10× range are real.
TIOBE perennial top 5
2025: Python · C++ · C lead the TIOBE chart; C++ has held a 30+ year top-five streak. New C++ repo growth on GitHub stays among the leaders — far younger than the "legacy language" stereotype suggests.