Is Rust a good first programming language?
Short answer: Rust is a harder first language than Python. Learn it first anyway if you want to be told about ownership and failure while you’re writing them, because Python won’t mention either until something breaks.
What Python hides
Section titled “What Python hides”a = [1, 2, 3]b = ab.append(4)print(a)[1, 2, 3, 4]Nothing in that program says a and b are the same list. Five lines make it obvious. A hundred lines, and a function that took items as a parameter, make it a bug report at a bad hour. Python isn’t doing anything wrong here; it just never asks you the question.
Rust asks. Assigning a Vec to a second variable moves it: ownership leaves the first name, and the next line that mentions it is a compile error, at your line, before anything runs. There’s a longer version of that in Why does Rust move values instead of copying them?.
Failure is in the type
Section titled “Failure is in the type”In Python, any call can raise, and the signature doesn’t say which. You learn a function’s failure modes by reading its source, or by shipping it.
A Rust function that can fail returns a Result, so the possibility is already in the type you’re reading. Leave the value unused and the compiler warns you about it. Same lesson, delivered before the program exists.
What it costs
Section titled “What it costs”Two things are worth knowing before you commit. The borrow checker will reject code that would probably have worked, and you’ll rewrite it instead of arguing. And every experiment goes through a compile step, so the feedback arrives late and all at once.
That’s the trade. It’s late, but it’s about the code you wrote rather than a traceback from a library you’ve never opened.
- How to try Rust without installing anything — a browser tab, no toolchain
- Compiler errors — how to read the messages you’re about to meet
- Should you learn Rust? — the rest of this chapter