Whether you’re taking up programming for the first time, or learning your 50th language, you might ask, “What’s the best way to learn to program?” I surveyed dozens of people who taught themselves to program in Rust as part of my OSCON talk in 2016, and asked the expert autodidacts what advice they would give to others for picking up a new language. I found that despite their diverse backgrounds, all of my interviewees shared five common approaches to building new programming skills.
1. Learn by doing.
Predicting what will happen when your code runs is, perhaps, the essence of programming. The best way to find out what will happen when a piece of code gets modified is to run it before and after that change, and compare the results.
Learning by doing will also help you hone your troubleshooting skills. If you’re able to run the code you’re studying at each step of a tutorial, you can easily guess how a modification will change its behavior and then check whether you were correct. Predicting your language’s behavior is the essence of programming: You decide what you want your program to do, write code that you predict will have that result, and then run it to see whether you were right.
2. Practice consistently.
You already know that frequent practice is essential to cultivating any new skill. But did you know that it’s even more important if the new thing you’re learning involves software? Because programming languages and the tools around them are constantly being improved, part of your study time will go to simply keeping up with your new language and ecosystem’s news and developments.
Additionally, practice consistently by using only a single major version of your new language until you’re confident in your grasp of its basic concepts. The best practices for accomplishing a given task often change as new language features are added. This means that if you jump around between major versions of a language, you’ll have to process conflicting advice about when to use the language’s various features, as well as trying to learn them! While it’s certainly possible to end up fluent in the language even if you study many different versions of it and its tools at first, the added complexity will slow your progress.
3. Start with the basics.
Letting a kid try to ride a motorcycle before they can balance on a bike is just setting them up for failure. Similarly, jumping into tasks that require skills you haven’t developed yet is a great way to set yourself up for an extremely frustrating experience in a new language.
If you’re learning from a book or tutorial, choose one that’s written for students at or below your own level of experience. When you’re brand new to programming, the amount of new material can seem overwhelming. But learning subsequent languages will be simpler, because you’ll already understand the basic concepts like variable assignment, comparison, and control flow.
Before you try to write an entire application from scratch, start with…