Learning How to Program

  • strict warning: Non-static method view::load() should not be called statically in /home/sigpboo7/public_html/modules/views/views.module on line 842.
  • strict warning: Declaration of views_handler_field_comment::init() should be compatible with views_handler_field::init(&$view, $options) in /home/sigpboo7/public_html/modules/views/modules/comment/views_handler_field_comment.inc on line 50.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/sigpboo7/public_html/modules/views/plugins/views_plugin_row.inc on line 135.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/sigpboo7/public_html/modules/views/plugins/views_plugin_row.inc on line 135.

Eventually, every programmer blogs about how to become a better programmer. It seems to be the price of admission to the industry. Programmers are a vain lot, and every one of us likes to think he has a unique viewpoint to contribute with insightful advice and meaningful guidance. The reality is that the “learn how to program” post is cliché. There are so many that each new one is nothing more than an echo of some old, vaguely-remembered, proto-learn-how-to-program-post. No one should write another. There’s no point.

So obviously I’m going to write another.

Programming is exactly like this.

The U.S. Needs Developers Like Whoa, So Good Answers are Hard to Find

Software development was one of the fastest-growing jobs in the United States in 2011 and was recently declared 2012’s best job of the year in the Wall Street Journal, so it’s no surprise that there’s so much interest in learning to be a developer. And there is interest: if you’re active in programming communities online at all, you run into posts asking “How do I learn to program?” every day.

Sites like StackOverflow get these questions all the time, and Reddit even has a whole subreddit dedicated to learning how to program. As the “digital generation” grows up and more people begin to use computers in their daily lives, more and more people are becoming interested in programming. (Of course, recent events have helped, too.)

This increased interest is great for the industry, but with the question of how to learn to program getting asked so often, it can be hard to find good answers among the thousands of different pages where this question has been asked.

But while you’re here, why don’t you check out my advice?

Step Zero: Prepare Yourself to Want to Quit

I’m sure many people say this about their fields, but programming is hard. Learning to program is probably one of the hardest things you will ever do. No, I’m not kidding, and I’m not being ironic. Learning to program is legitimately difficult.

So, before you even start, prepare yourself for failure. Prepare yourself to feel really, really stupid. Prepare yourself to try, try again, and try some more, and ultimately get nowhere. Prepare yourself for these things, because these things will happen on a daily basis. (At least while you’re learning.) The hardest part of learning to program is sticking with it.

This all sounds dire, but trust me: learning to program is worth it. A hundred times over.

Anyway, since you’re going to fail — a lot — the best thing you can do is steel yourself, and then approach learning to program so you succeed as much as possible. Always keep this in mind.

Step One: Pick a Language

The first thing you’ll need to do is pick a language to learn first. For reasons of simplicity, Python is a great place to start, but there are good reasons to go with other languages, too. JavaScript is extremely dynamic and has been undergoing something of a renaissance over the last 5 years or so as browsers have finally started to really mature, so it can provide new programmers with the kind of “gee whiz” instant gratification they need to stay motivated. PHP is another common first language because it lets beginners get whole websites up and running quickly, but I personally have to recommend against it because as a language, PHP is terrible. (It’s OKPHP’s creator, Rasmus Lerdorf, is on record agreeing that PHP has no real coherent design strategy or structure.)

Step Two: Pick a Tutorial, and Stick With It

When learning to program, your first priority has to be getting something working. Remember, learning to program is hard, and without some kind of feeling of accomplishment, you’ll never stick with it. So, whatever language you choose to start with, find a tutorial and stick with it to the end. If you’re serious about learning to program, you need to invest at least that much.

It’s been a while since I learned to program, so unfortunately I can’t recommend any really good tutorials. However, a quick Google of Python tutorials surfaces several that look pretty good.

Step Three: Pick a (Simple) Project, Finish it, Rinse, Repeat

Programming is not something to be understood in theory; It is something to be practiced. The best way to learn to program is to program. So, the very best way to learn to program is to pick a project, build it, and then do it again.

Start with really simple projects — projects so simple you’re almost embarrassed — and actually finish them. (These little victories will make you disproportionately happy. Enjoy it.) At this stage, never start a program that you don’t almost know how to do before you start, or else you’ll get discouraged and quit halfway. Instead, choose projects that focus on one key new skill and exercise it, while applying the skills you’ve already picked up.

Having trouble coming up with a simple project? How about Hello World? How about FizzBuzz? Have you written code to print out the first 100 fibonacci numbers? Have you thought about how to make a simple password generator? A “Find and Replace” program for text files? How about a simple web search for beginners’ programming projects?

No project is too simple at this stage. The goal is to build up a feeling of success and confidence, so don’t be afraid to start really small.

What’s Down the Road?

Once you’ve done enough programming to get hooked on it — you’ll know when it’s happened — you can start taking on more and more complex projects. Maybe you’ll finish them, maybe you won’t, but you will learn a lot, and you will keep programming. Once you’ve hit this phase, study everything. Tried 3D programming? How about a REST-y API? Analytical software? Again, these projects don’t have to change the world, but the more you learn the more you know, and the more you’ll want to know.

Dun DUN dun DUN

And, because no “Learning to Program” post would be complete without this list, here are a couple more things to keep in mind as you’re learning to program:

  • The Scientific Method is not just for Science. One of the most important skills you can develop as a developer is problem solving. When you’re sitting down to program, don’t just edit code and run it willy-nilly until it starts to work. Instead, make a change to your program, form a hypothesis about your program’s behavior, and then run your program to test your hypothesis. You’ll be so grateful for this skill one night when you’re looking for a bug at 3AM. (Don’t ask how I know.)
  • Trust your Tools. On the whole, programming languages and popular libraries are supremely battle-tested. If you’re trying to figure out why your code isn’t doing what you think it should, assume you have a bug, not your tools. This approach will be right 95% of the time.
  • Find all magic and destroy it. Learning to program is an iterative, systematic process of eliminating magic. While you won’t necessarily understand every detail of your program at every level, make sure you understand every call in your program, what it does, and how it works. When you find something in your code that works but you don’t understand why, such as code from a tutorial or an example online, research it until you do understand. Again, you’ll be so grateful you took the time to do this one night when you’re desperately trying to find that last bug at 3AM. Trust me.