0.1Introduction to these tutorials
Welcome! You've found a free set of tutorials that will teach you how to program in Rust. No prior programming experience is required. If you've never written a line of code in your life, you're exactly who these lessons are written for.
Plenty of Rust material already exists for people who know another language. Much less exists for people starting from zero, and that's the gap this site fills: small lessons, taken in order, each teaching one thing well.
How the course is organized
Lessons are grouped into numbered chapters, and each chapter covers one subject. Lesson numbers work like chapter.lesson, so lesson 4.2 is the second lesson of chapter 4.
Chapter 0 (you are here) is about getting ready: what programs actually are, where Rust came from, and how to install everything you need. You won't write any Rust in this chapter. Resist the urge to skip it anyway, because the vocabulary introduced here (compiler, build, crate...) gets used constantly in the chapters that follow.
Chapter 1 takes a first pass over the core of the language: wide and deliberately shallow, so you can write small programs of your own as quickly as possible. Later chapters then come back around for depth. If something feels lightly explained on first contact, that's usually on purpose, and we'll say so when it is.
Work through the lessons in order. Each lesson assumes you've read the ones before it.
Our goals
A few promises about how these tutorials are written:
- Teach programming, not just Rust. Languages come and go; the underlying ideas (how to structure a program, how to reason about what it does, how to hunt down a bug) transfer everywhere. Where understanding why something works requires a detour, we take the detour.
- Show lots of examples. Most people learn more from examples than from definitions. Every concept comes with code you can compile and run yourself, and (starting in chapter 1) every example compiles as shown unless we explicitly break it on purpose. When we do break one, we'll show you the exact error it produces.
- Provide practice. From chapter 1 onward, most lessons end with a short quiz, and every quiz comes with full solutions you can reveal when you're ready. The chapter-ending quizzes finish with a small program for you to write.
- Have fun. Programming, done at your own pace with working examples, is one of the most satisfying things you can learn. (Done at 2 a.m. before a deadline, less so. We'll aim for the first kind.)
How to get the most out of each lesson
Type the examples in by hand. Don't copy and paste. Typing the code yourself builds the muscle memory for the syntax, and the typos you make along the way are quietly valuable: learning to read the compiler's complaints is a core skill in Rust, and your typos are free practice.
When you break something, fix it before moving on. You will make mistakes constantly. So does every professional programmer alive. The difference is that they've gotten fast at finding and fixing them, and debugging your own broken program teaches you more than reading ten working ones.
Experiment. Change the examples. Make the program print something else, feed it strange input, delete a line and see what the compiler says. The cost of a failed experiment in programming is zero, which makes it the cheapest laboratory in any field of engineering.
Do the quizzes. Reading a solution feels like learning; writing one is the real thing.
Common questions
Q: Do I need an account? How much does this cost?
No account, no cost. Everything on this site is free, and there's nothing to sign up for.
Q: Is there a PDF or offline version?
No. The lessons get revised continuously as readers report what's confusing, so a PDF would just be a snapshot of the site at its worst (every version is the worst version, looking back).
Q: What do I need to get started?
A computer running Windows, macOS, or Linux, and an internet connection for the installs. Everything you'll install is free, and we'll set it all up together in lessons 0.6 and 0.7.
Q: What if I get stuck?
First, re-read the lesson — slowly, the second time. If you're staring at an error, read the whole error message; Rust's are unusually helpful, and lesson 0.9 covers what to do when one stumps you anyway. And sometimes the best move is to sleep on it. Bugs are noticeably easier to find in the morning.
Let's get started. First up: what a program actually is, and what's really inside the files you're about to create.