Welcome — Programming, and Why Rust
Starting from scratch: what a program is, and what makes Rust different
A language that started as one engineer’s nights-and-weekends side project now runs inside your browser, your operating system, and the servers behind your favourite apps. It is loved more than any other language on Earth, and it earned that love by being stubborn.
This is the story, and the mechanics, of why.
This curriculum assumes Rust is your first programming language. If you’ve coded before, the early lessons will move slowly — skim them. If you haven’t, every word matters; read it in order, don’t skip.
The goal isn’t to make you a Rust expert in a weekend. It’s to give you a working mental model of how a program executes, and how Rust specifically helps you build one without the categories of bugs that have plagued every other systems language for fifty years.
What is a program?
A program is a sequence of instructions that a computer follows. You write the instructions in a programming language — a language designed to be unambiguous so a computer can carry them out exactly. Different languages have different strengths. Some are tuned for quick experimentation, some for absolute speed, some — like Rust — for safety and speed at once.
A program does three kinds of thing:
- It holds data. Numbers, words, lists of things, files, network connections.
- It transforms data. Adds two numbers, splits a sentence into words, sorts a list.
- It produces output. Prints to your screen, writes a file, sends data over the network.
That’s it. Every program you’ve ever used — your browser, a game, the text editor these words were written in — is some elaborate combination of those three.
A few words you’ll need
Some terms come up constantly. Quick definitions, then we’ll see each in action:
- Variable: a name attached to a piece of data.
let age = 30makesagepoint at the number30. - Type: the shape of a piece of data.
30is a number;"hello"is text;trueis a yes/no value. Knowing the type means knowing what you can do with it. - Function: a named piece of code that takes some inputs and (usually) produces an output. Like a recipe: name, ingredients, steps, result.
- Memory: the computer’s workspace, where data lives while the program runs. It has limits, can fill up, and reading or writing the wrong part causes crashes.
- Compile: the step where your text-file source code is converted into a runnable program (an executable or binary). The tool that does this is the compiler.
- Compile time vs runtime: “compile time” is when the compiler is reading your code; “runtime” is later, when the resulting program is actually running. Rust shifts many bugs that other languages catch at runtime to compile time, where they’re cheaper to fix.
What is Rust?
Rust is a systems programming language — meaning it can produce small, fast programs that run close to the metal: operating systems, browsers, databases, embedded devices. C and C++ have owned that territory for decades. They produce fast code, but they’re famously easy to crash: a forgotten check, a bad pointer, two threads stepping on each other’s data, and your program corrupts memory or, more often, just silently does the wrong thing.
Rust was built to be just as fast as C, but with the compiler enforcing — at compile time, before you even run the program — that those bugs are impossible to write. The defining feature is the borrow checker: a part of the compiler that tracks who owns each piece of data and refuses to build if you try to use data in an unsafe way.
The friction is the point. Rust is picky in the way a flight instructor is picky: every refusal is a lesson, and once you internalise the rules you stop making the class of mistake the rule was protecting you from.
The shape of the smallest program
Here’s the smallest complete Rust program. Don’t worry about understanding every character yet — just look at the shape, then change it and run it for real. (The code box below talks to the official Rust Playground, so the “Run” button compiles your edit with a real Rust compiler and shows you exactly what it prints.)
Three things happen:
fn main() { ... }defines a function calledmain. Rust starts every program by running the function namedmain. The{and}braces wrap the function’s body.let greeting = "hello, world";creates a variable calledgreetingand points it at the text. The semicolon ends the instruction.println!("{greeting}");calls a built-in tool calledprintln!(the!marks it as a macro — for now, treat it as “print a line”). The{greeting}gets replaced with the value ofgreetingwhen the program runs.
Try editing the greeting in the box above and hitting Run again. You just compiled Rust.
Why the compiler argues with you
If you’ve heard about Rust before, you’ve heard people say it’s hard. What they mean is the compiler rejects your code more often than other languages would, with longer error messages. That’s true. What’s also true:
- The error messages tell you exactly what’s wrong and frequently suggest the fix.
- Once your code compiles, it works far more reliably than equivalent code in most languages.
- The mental model is small. Three or four core rules carry almost everything else.
Watch it happen. The program below tries to add a number to a piece of text — nonsense, and Rust refuses to build it. Hit Run and read the error; this is the picky-compiler experience in one screen.
Notice what didn’t happen: the program never ran and did something weird. The compiler stopped it at the door and explained why. In many languages this same mistake slips through to runtime and corrupts your output silently. Rust shifts the failure earlier, to the cheapest possible place to fix it.
A short history of a stubborn language
Graydon Hoare starts Rust as a personal project. The earliest compiler is written in OCaml, since Rust can't yet compile itself.
Mozilla begins sponsoring Rust, betting it can power Servo, an experimental, parallel browser engine that C++ made too dangerous to write.
Rust is announced publicly for the first time. The ownership-and-borrowing model that defines the language is still years from settling.
Rust 1.0 ships. From here on, code that compiles is promised to keep compiling — the stability guarantee that made companies willing to adopt it.
The Rust Foundation forms, backed by Amazon, Google, Microsoft, Mozilla, and Huawei. Rust soon lands in the Linux kernel — the first language besides C and assembly allowed there in three decades.
What you’ll learn here
The next twelve lessons walk through Rust in roughly this order:
- Foundations (you’re here, plus lessons 1–3): how a Rust project is laid out and run, how variables and types work, how to make decisions and repeat work.
- Ownership & Borrowing (4–6): the unique-to-Rust rules about who owns data, who can read or write it, and how memory is freed automatically.
- Types & Traits (7–9): how to define your own kinds of data, share behaviour across many types, and build pipelines that transform data.
- Errors & Options (10): how Rust handles things that can go wrong without exceptions.
- Concurrency (11): how Rust runs multiple things at once without the bugs that plague other languages.
- Capstone (12): a small real program that uses every concept above.
Every code box in this course runs for real — edit it, break it, fix it. That feedback loop is the fastest way to learn.
Why 'systems language' actually matters
Most popular languages — Python, JavaScript, Java, Go — run on top of a runtime that manages memory for you using a garbage collector: a background process that periodically scans for data no longer in use and frees it. Convenient, but it costs CPU time and introduces unpredictable pauses, which is unacceptable for an operating-system kernel, a game engine at 120 frames per second, or a tiny microcontroller with kilobytes of RAM.
Systems languages (C, C++, Rust) have no garbage collector. In C and C++ that means you manage memory by hand, and a single mistake — freeing the same memory twice, using a pointer after the data is gone — corrupts the program. Rust’s bet is that the compiler can prove your memory use is correct at compile time, giving you C-level speed with no garbage collector and no hand-managed-memory bugs. The rest of this course is mostly about how it pulls that off. The key idea has a name — ownership — and it’s lesson 4.
Key takeaways
- A program is instructions that hold, transform, and output data.
- Variables name data; types describe what the data is and what you can do with it; functions are named recipes.
- Rust is fast like C, but the compiler refuses to build programs that would crash from common memory or threading bugs.
- The borrow checker is the part of the Rust compiler that enforces those rules. It’s a co-author, not an opponent.
- The next lesson installs Rust and runs your first program. Read it next.
Rust asks more of you at the start than almost any other language. In return it hands you something rare: the confidence that if it compiled, whole categories of bugs simply aren’t in there.
That trade — a little more thought now for a lot less debugging later — is the entire bet. The next twelve lessons teach you how to win it.