How to Learn a New Programming Language or Framework

Chapter 2 · Practice 2 of 4

Type the examples and change them, do not just read them

From Start with the official documentation

Why it matters

Reading code feels like learning, but it mostly builds a sense of familiarity. Typing examples, running them and then changing them builds real understanding.

For each example in a tutorial:

  1. Type it rather than copy it. You notice details you would skim.
  2. Run it and check the output matches what you expected.
  3. Break it on purpose: remove a line, change a type, pass bad input.
  4. Read the error. You will meet that error again in real work.

The Rust Book is a good model: it mixes concept chapters with project chapters, such as a guessing game, a command line tool and a multithreaded web server, so you build as you go.

Do

  • Run every example and then modify it
  • Break examples deliberately to see the errors

Avoid

  • Reading a whole tutorial without opening an editor