John Jago

Learn programming by doing

In programming, one of the most effective ways to learn is to start trying to make whatever it is you want to make.

For example, suppose you want to write a program that takes an image as input and produces four images, as if you were to cut the image into quarters with a pair of scissors. Maybe your friends need this too, so you decide to make it available through a web interface. By setting out to make this, you force yourself to learn exactly what you need to accomplish your goal.

To get started, you need to choose a programming language. This will probably be one you already know, or it can be a new one if you really want to learn a lot. You have to think about how this program will run. As a command line tool? If that’s what you want, you’ll have to keep the web interface in mind. How will you write it so that the same code can be reused for both the command line tool and the web interface?

As you write the code, you’ll discover libraries for image manipulation, or maybe even write your own! Depending on how familiar you are with the language, you might learn new techniques or concepts to write the code as cleanly as possible.

Approaching a project in this way will involve a lot of reading. Blog posts, Stack Overflow questions, tutorials. You’ll be reading about what people have done to solve the same (or similar) problems. You take their approach and modify it to suit your needs. When you don’t have the exact solution but something close—this is a lot of fun. You have to figure out what the code is doing instead of just copying it into your project.

There may be times when you do it one way, only to find out later that what you did was a horrible way to do it. Then you go back and rewrite that piece. It’s an iterative process, especially when you’re doing something for the first time. You not only learn from reading about what others did, but you also learn from yourself.

Although learning by doing teaches you a lot, it shouldn’t be the only way you learn about programming. Sometimes you have to go out of the way to expose yourself to completely new concepts. Only after you are aware of those new concepts can you start to think about ways to use them in a project. Also, sometimes a little background information is necessary to get started successfully. For example, consider machine learning. Without the necessary background in statistics, it can be really hard to understand why things work. In this case, spending some time to read about the background before doing a project will be well worth the time.