Mar. 20, 2012
12:06 am


How to learn to code: Don’t learn how to code

These notes are compiled from a session I attended at SXSW called “Learn to Code and Make the Software You Want.” A lot of what the session organizers (Nate Westheimer and Vin Vacanti) said rang true, and they managed to outline the path to coding better than anyone else I’ve heard speak on the subject.

Nate and Vin said there was only one prerequisite for learning to code: you need to build something. You have to have a problem in front of you that will drive you enough to want to solve it. That problem can be anything (building a personal website, manipulating some data in a unique way, fixing a Twitter widget), as long as the answer is writing or editing code to solve it.

This year, I tried Codecademy, which is designed to teach you JavaScript through some basic tutorial lessons. It takes the approach of a foreign language class, where the idea is to get you speaking the language and saying phrases as quickly as possible, which is kind of empowering. The thing was, I got bored with it — it’s really hard to just academically learn a programming language. You need some reason to be learning it, which is why you need a problem to solve. With programming, you don’t learn by learning; you learn by doing.

Perfection is the enemy

So once you have a the problem in front of you, start stealing and editing code to get it to do what you want. Don’t worry if it’s clean — no one starts off writing code the “right” way.

This can be the hardest part. If you’re a perfectionist, you want to do it right from the very beginning. If you’re afraid of doing something wrong, you won’t have the courage to fail and learn from your mistakes. The thing is, you have to experiment until you have a bit of programming that does something. Then you can see what it’s doing and fix it.

(I’ve had moments when I’ve worked on something for a while and finally got an error message out of it — and I was relieved. “It’s finally doing something!” Not working, broken, and working are parts of a richer spectrum than it might seem.)

Getting started

How you get started is up to you. Once you learn the basics of one language, you have enough of a foothold to take that knowledge to another language.

My personal trajectory has been learning snippets of JavaScript occasionally to pair with my HTML and CSS skills, followed by learning PHP through WordPress and Drupal. I now use Python to do some scripting, but nothing web-based like Django (yet). I haven’t touched Ruby at all yet since I haven’t had need.

One of the key moments for me was getting MAMP running for the first time and playing around with a WordPress install on my machine. MAMP mimics a web host and all its parts. It meant that I had immediate access to all the files I was working on, and it also meant that if I ever really broke something, I could start from scratch without worrying too much about it. So I could even dig around in MySQL without the “oh no I broke it” feeling. MAMP is PHP-based, so it’s best for playing around with WordPress and Drupal.

Resources for when you’re stuck

Google. I sent out a tweet earlier today alluding to the fact that coding means having many tabs open. Every problem you’re having, someone else has likely had. It doesn’t help that sometimes this stuff makes no sense. Google will lead you to sites where people have discussed your exact problem. Just hope that they leave you with the solution too. Googling your problem has another benefit: you’ll learn stuff along the way. You’ll have to comb through similarly-worded questions and learn things tangential to solving your problem. All of this helps in the long run. Sometimes the answer you’re looking for is a footnote to another semi-related problem, but you’ll gain the knowledge in the entire thread as you’re sifting through it.

Stack Overflow is an awesome question and answer community. Odds are, Google will send you here for your coding conundrum. I’ve never asked a question, but I’ve heard that people will get back to you very quickly (as long as you politely ask your question in the right way and provide enough information for it to be answered).

When all else fails, it’s good to have a patient friend. Someone who will put up with your panicked instant messages and emails. It’s best to try and solve it on your own, but it’s always good to have someone to fall back on to point out something stupid you forgot. (Like a semicolon.) I usually start running at people screaming right after I’ve started tearing my hair out. Help me Obi-Wan Kenobi, you’re my only hope.

Language documentation

The official PHP manual is good for syntax and parameters for certain functions (I think I’ve looked at the date parameters more times than I’d like). For any WordPress-related issues, I’ll check the WordPress Codex before I go anywhere else. If there’s not a page that addresses my particular issue, there may be a forum thread that gets at it.

The Python documentation is more formal than the PHP documentation in my opinion. It’s still handy. I’ll often use the Python manual to more accurately Google for my problem.

This is in no way thorough, but it can’t be. Coding is something where you really have to get thrown into the deep end and find your way out again. Nate and Vin called it “the Sweat Lodge,” where you isolate yourself and just focus on making something work (or even breaking something so you know how it works). It’s not as hard as it seems.

Once you get started and get that initial traction, you can build amazing things. And it’s an awesome feeling to build something that works.