Why You Will Actually Like Rust
The one-paragraph pitch
You have probably shipped code that crashed because something was None, or null, or undefined, when you thought it was not. You have probably debugged a race condition that only happened on Tuesdays. You have probably watched a server leak memory and restarted it on a cron job. Rust is a language whose entire personality is “what if we just made those bugs impossible to compile?” That is it. That is the whole pitch.
A small amount of friction up front, a large amount of peace later
The four bugs Rust deletes
The same four bugs have eaten more engineering time than every other category combined. Rust removes them at compile time.
- Null / None surprise. You think a value is there. It is not. In Rust you cannot even ask for a value without first answering "what if it is missing?"
- Data race. Two threads write to the same variable without coordinating. In Rust this is a compile error, not a Heisenbug.
- Use-after-free. You free memory, then accidentally read from it. In Rust the compiler will not let that code link.
- Silent failure. A function quietly returns a default when something went wrong. In Rust, errors are ordinary values you cannot forget to look at.
Before you read a single chapter, watch the pitch in action: here are the four bugs, and here is the compiler deleting each one.
Interactive simulation (requires JavaScript): the four memory and concurrency bugs — use-after-free, double free, dangling pointers, and data races — each shown with the compile-time error or ownership rule that deletes it in Rust.
Rust has a reputation for being hard. The reputation is half deserved. The half that is deserved is real: Rust asks you to think about one thing most languages let you ignore — who is allowed to touch a piece of data, and when. That is the idea behind ownership. It is not complicated, it is just new, and like anything new it feels awkward for about a week.
The half that is not deserved is the rest: Rust’s syntax is not weirder than TypeScript’s, its tooling is better than almost any other language’s, its error messages are the best in the industry, and its documentation is excellent. Once the ownership idea clicks — and Part 0 is built to make it click fast — the rest feels like any other modern language, just with fewer 3 a.m. pages.
Who this book is for
If you can read JavaScript, Python, or TypeScript without a dictionary, you can read this book. We assume you know what a variable, a function, and an if are. We assume nothing else.
If you have written C or C++, you will move faster through Part 0. If you have not, nothing in Part 0 requires you to.
How to get the most out of it
Three rules.
- Run every code example. Every block has a “Run in Playground” link. Click it. Change a number. Re-run it. This costs you thirty seconds per block and saves you thirty minutes of re-reading.
- Do not skip the pictures. The SVG figures carry at least half the meaning of this book. The prose is the caption; the picture is the point.
- When the compiler shouts at you, read what it said. Rust’s compiler is a senior engineer looking over your shoulder. Its error messages usually tell you exactly which three characters to change. The habit of reading them carefully is the single biggest thing that separates frustrated Rust beginners from happy ones.
Ready? Hello, Rust →