Level 0 · Foundations

How a Computer Thinks 🧠

Before you tell a machine what to do, it helps to know what the machine actually is. Ten minutes here makes everything after feel less like magic and more like engineering.

A very fast machine that only does simple things

Here is the whole secret of computing: a computer is not smart. It performs only tiny, dumb operations (add two numbers, copy a value, compare, jump to another instruction), but it performs billions of them per second, perfectly, without getting bored. Everything you have ever seen a computer do, from Netflix to spreadsheets to this website, is built from those tiny steps stacked very, very high.

Programming is the art of writing those steps down. You are not summoning magic. You are writing an extremely precise recipe for an extremely fast, extremely literal cook.

The kitchen: CPU, memory, and storage 🍳

Think of the computer as a restaurant kitchen:

A "program" at rest is just a file in the pantry. Running it means the chef starts reading its instructions and using counter space for its ingredients. When Lesson 6 says memory must be given back, this countertop is the thing being managed.

Binary: why ones and zeros?

Deep down, a computer stores everything as electrical switches that are either on or off. Write on as 1 and off as 0 and you get binary. With enough switches you can encode anything: the number 42 is 101010, the letter A is 01000001, and a photo is millions of such patterns describing pixel colors.

You will almost never work in binary. But it explains vocabulary you will meet constantly: a bit is one switch, a byte is eight of them, and the number types you will meet in Lesson 3 (i32, u8) are literally named for how many switches they occupy. An i32 is a number stored in 32 switches. That is the whole mystery.

From your words to the chef's language

The chef speaks only machine code: raw numeric instructions. Humans are terrible at writing it directly, so we invented programming languages, which are human-readable notations that get translated for the chef. There are two big translation styles:

Compiled (Rust, C, Go)Interpreted (Python, JavaScript)
How it runsTranslated fully to machine code first, then runs nativeA helper program reads and executes your code line by line
SpeedFast (the chef reads native recipes)Slower (a translator whispers each step)
Error catchingMany mistakes caught before the program ever runsMany mistakes discovered only while running
ShippingOne standalone file you can hand to anyoneThe user needs the interpreter installed too

Rust is compiled. That is why the workflow you will learn is write, compile, run, and why the compiler (rustc) gets to inspect your whole program and refuse it if something is unsafe. A strict translator is annoying for five minutes and priceless for five years.

What an operating system does

One more character: the operating system (macOS, Windows, Linux) is the kitchen manager. It decides which programs get CPU time, hands out memory, guards files, and provides services every program needs (drawing windows, reaching the network, reading the keyboard). When your Rust program prints text or opens a file, it is politely asking the OS to do it. The web server you will run in this course asks the OS for a "port" to listen on. Same idea.

💡 Why this matters for Rust specifically Rust's famous features are kitchen management: ownership (Lesson 6) is about returning counter space promptly, and fearless concurrency (Lesson 16) is about several chefs sharing the kitchen without collisions. Knowing the kitchen makes the rules feel obvious instead of arbitrary.
Exercise 1

Meet your own kitchen

Open your machine's task viewer (macOS: Activity Monitor, Windows: Task Manager, Linux: htop or System Monitor). Find: how many programs are running right now, which one uses the most memory, and how many CPU cores you have. Any surprises?

Reveal thoughts

Most people are shocked twice: dozens of programs are running that they never started (the OS's own helpers), and the browser eats more memory than almost anything else. You also now know your core count, which will matter when you write threaded Rust in Lesson 16.

Exercise 2

Binary by hand

Binary is just place values doubling: 1, 2, 4, 8, 16, 32... So 101010 means 32 + 8 + 2 = 42. Decode these: 1000, 1111, 100000. Then write your age in binary.

Reveal answers

1000 = 8. 1111 = 8 + 4 + 2 + 1 = 15. 100000 = 32. For your age, keep subtracting the largest power of two that fits. For example 34 = 32 + 2 = 100010. You will never need this daily, but now the machine's alphabet holds no fear.

Exercise 3

Explain it forward

Teaching locks in learning. Explain to a friend (or a rubber duck, or your cat) what happens between double-clicking an app and it appearing on screen, using the kitchen analogy. One minute, out loud.

Reveal one version

"The app is a recipe file in the pantry. The kitchen manager copies it to the countertop and tells a chef to start reading. The chef executes millions of tiny steps, some of which ask the manager to draw pixels in a window. All of that happens before your finger leaves the mouse."