A post I read the other day about learning to program prompted me to jot down a few quick tips based off of my experience learning to program.
Don’t worry about speed
In your first year of programming the chances are near 100% that all of your code will be slow. Don’t bother trying to optimize your programs, spend your time instead on learning and using basic data structures and algorithms.
Challenge yourself, but don’t try to do the impossible.
When you pick projects as a beginning programmer you will be tempted to want to create the next big innovation in software. However this road is long and hard and you will be battered with defeat along the way. Instead, try to pick simple things that you can accomplish in a month or two and are just a little bit outside your abilities.
Don’t worry about the right way to do it, but only at first.
In the beginning you’re going to write bad code. However writing bad code can be a great motivating factor to learn to write better code. For instance, writing code to print each element in an array by hand would be great motivation to learn how to use loops. In the beginning you want to get a feel for programming, what works and what doesn’t and what all those names you hear about actually do in the computer. After you’re comfortable building small toy programs you can start learning the right way to do things.
Stick with one language, for now.
You have probably scoured the internet trying to figure out which language to start with. I’m sure you’ve come across posts by people telling you to learn a lot of languages. I agree with them, any experienced programmer should learn lots of languages (or at least a couple very different ones). However you’re not experienced yet and will only get lost in a sea of syntax. Pick a language and stick with it for a year at least, I recommend Python.
Your first programs should have some kind of visual feedback.
With visual oriented programs like games or GUIs you can see your program performing right in front of your eyes. Not only is this great motivation, as your results are immediately available, it is also a great learning experience. A good place to start is vpython which gives you a 3d world to play in that is very simple to code.
Read code, but read the right code.
Learning to read code is a must. However don’t just grab the sources to Firefox and have at it. To start learning to read code I recommend reading libraries for the language you program in. Libraries are often written in a functional style that doesn’t require you to chase all over the place looking for definitions and keeping state in your head. Of course this can vary widely based on the language/libraries you are reading.
Throw away all the code that you wrote in your first year.
OK that might be a little harsh, you may have a few gems. The vast majority of your code, however, belongs in the trash (or in your archives to bring out for amusement and reminiscing about the old days).
You will find, as you progress through your journey to enlightenment, that when you look back at previous non-trivial code you wrote you will mostly think “Why did I do that!?!” In the case that this is not true you have either reached the pinnacle of enlightenment or have stopped caring about learning new things (it is almost universally the latter).
If you enjoyed this article you may like: Which programming language should I learn