Week 18 · Phase 3 — The Architect
Bjarne Stroustrup's vision — the leap that turned C into a language for building anything.
Photo · Amsterdam City Archives / Unsplash
By 1979 C was already a smash hit. UNIX ran on it. Most universities used it. The first generation of microcomputer compilers was shipping for it. But there was a kind of program C wasn't great at: the ones with thousands of moving parts. A simulation. A graphical workstation. An office-productivity suite. Something with hundreds of types of object, all interacting, all needing to evolve over decades.
You could write those programs in C. People did. They were enormous, brittle, full of "manual conventions" — naming things customer_create and customer_destroy and hoping nobody forgot to call destroy. The same Bell Labs that gave us C noticed the friction. A Danish PhD student named Bjarne Stroustrup, who had spent his thesis on a simulation language called Simula, decided to do something about it.
Stroustrup arrived at Bell Labs in 1979. He needed to write large simulations and was not enjoying the experience in C. Simula 67 — the language he'd used for his thesis — had introduced something new: classes, a way of bundling data with the operations on that data. Simula was elegant, but slow.
Stroustrup's idea, which would absorb the rest of his career, was: take Simula's classes, and put them on top of C, with no runtime overhead. Keep all the speed. Add the organisation. He started writing a preprocessor he called C with Classes, which translated extended C source into ordinary C, which then compiled normally.
By 1983 it was real. By 1985 the language had a new name and a book — The C++ Programming Language. The ++ was a deliberate joke: "C, with one increment". By 1989 ANSI began standardising it. By 1995 Microsoft had built Windows partly in C++. By 1998 the first ISO C++ standard shipped. By 2024 you could not pick up an AAA video game, a database engine, a browser, a flight-control system, a phone OS, or an AI inference framework that did not have a substantial chunk of C++ in it.
C++ added a long list of features over the decades — but the core, the part you'll spend Phase 3 learning, is small. Five ideas:
Together those five ideas form what people call object-oriented programming. They didn't originate in C++ — Simula had them, Smalltalk had them, even Lisp had them — but C++ made them fast, and that's what mattered. Object-oriented programming with no runtime cost. That combination took over the industry for forty years.
To make this concrete, consider how you'd represent "an account with a balance" in C and in C++.
struct Account {
int id;
double balance;
};
void account_init(struct Account *a, int id) { a->id = id; a->balance = 0; }
void account_deposit(struct Account *a, double amt) { a->balance += amt; }
double account_balance(const struct Account *a) { return a->balance; }
// caller side:
struct Account a;
account_init(&a, 42);
account_deposit(&a, 100);
printf("%.2f\n", account_balance(&a));
It works. Notice the convention: every function is named account_* and takes a pointer to Account as its first argument. There's nothing in C that forces this convention; you maintain it by discipline. If somebody adds an account_close function and another team member doesn't know about it, they might write their own. Naming collisions are real. Documentation is the only glue.
class Account {
public:
Account(int id) : id_(id), balance_(0) {}
void deposit(double amt) { balance_ += amt; }
double balance() const { return balance_; }
private:
int id_;
double balance_;
};
// caller side:
Account a(42); // constructor runs automatically
a.deposit(100);
std::cout << a.balance();
Same data. Same operations. But three differences are real:
a.deposit(100), and C++ automatically passes &a as a hidden first argument (the famous this pointer).id_ or balance_ directly. Only the methods can. You're guaranteed that only deposit can change the balance.The C version could achieve all of this with discipline and naming conventions. The C++ version has the compiler enforce it. That's the entire pitch of object-orientation. Compilers, not memos.
The biggest open-source AI frameworks — PyTorch (libtorch), TensorFlow's core, ONNX Runtime, llama.cpp's core code, NVIDIA's TensorRT — are all C++ codebases. Tens of millions of lines, evolving for over a decade, written by hundreds of contributors. None of those projects are realistic without classes, encapsulation, and inheritance. The OO discipline is what lets a thousand-engineer AI framework not collapse under its own weight.
You will probably never write a deep AI framework yourself. But you may very well find yourself debugging one, reading its source, or writing a small extension to it. The C++ you're about to learn over the next ten weeks is exactly the C++ those codebases use. By Week 28, you'll be able to open a PyTorch .cpp file and not feel lost.
C taught you the chef's vocabulary. C++ teaches you to organise a kitchen brigade.
public, private, the contract you make with everyone reading your code.unique_ptr, shared_ptr, and the rule of "no raw new".By the end of Phase 3 you'll have a working C++ skeleton in your head. The second half of the course (capstone projects, native UI bridges, AI tooling) builds entirely on that.
c++ --version on macOS or Linux. Save the C++ Account example as account.cpp, with a main() at the bottom that uses it. Compile with c++ -std=c++17 account.cpp -o account.include/. You'll see classes, public/private, methods. By Week 28 it'll be readable.We start tomorrow with the centre-piece of all of this — the difference between a class (a description of a kind of thing) and an object (an actual living, breathing instance of that kind). The blueprint and the building.
Week 19 is The Blueprint.
Photo free under the Unsplash license. Blueprint · Amsterdam City Archives.