A few best practices will help you pick up new programming skills.
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 the basics by acquainting yourself with the language, its package manager, and the editor plugins and testing tools that you’ll need.
4. Respect languages’ differences.
Many languages have idiomatic patterns to how people code in them. Although forcing your old language’s idioms onto code in your new language is possible, you should try to learn to have a more flexible coding style. Writing code with the “nature” of your new language will make it easier for others to read, critique, and help you improve.
You can learn your new language’s idioms by reading popular open source code written in it, and explore their philosophies by reading blog posts and articles by experts. As you progress, consider asking a more expert programmer to review your code and offer feedback on how easy it is to read.
If a unique feature or idiom of your new language doesn’t make sense to you, don’t be afraid to ask about it. You’ll get the best answers by asking respectfully and without judgment. “I’m new to this language, and I noticed that everyone seems to do X instead of Y. Where could I learn the story behind that pattern?” will probably get you a fascinating historical anecdote, whereas “X makes no sense, you should do Y instead” is likely to elicit an equally intolerant response.
5. Build something you love.
You don’t have to build the same toy project as a book or tutorial just because an expert suggested it. If you’re building some code just to learn a language, it could be anything. Choosing a project that interests and delights you can help motivate you to spend more time on your learning, imagine and ask better questions, and keep pushing forward when you encounter challenges.