The Path to Learning Programming Languages

Do you want to learn a new language? Spanish? Chinese? Ruby? Maybe Python? The cognitive benefits of learning a second language are well documented. While it’s not clear if learning programming languages impart the same mental benefits, it is still helpful to have a repertoire of languages. Some languages are great for processing text, others work best on embedded or mobile devices. Different languages lend themselves to solving different problems.

What’s the best way to go about learning a new programming language? We can take cues from the way in which we tend to learn spoken languages. That is, the non-programming kind we use to communicate with other human beings. There are many parallels between the two and the techniques are surprisingly similar.

Learn Phrases

Many of us begin learning a new language by picking up a few words and phrases. Maybe we use a phrasebook or a section in the back of a travel guide. “How much is that?”, “Thank you.”, “Where is the bathroom?” We learn just enough to get around and enjoy our international vacation.

This is really just cut-and-paste programming. When I’m first learning a new language, I tend to look for working examples online or in books. I take those examples, copy them, and modify to meet the specific need I have. I haven’t really learned anything about “grammar” or “sentence” structure, but it gives me the desired result.

For many applications, this can be just fine. If you only need to learn a language when you go on the occasional vacation to sip fruity drinks on the beach, there’s no need to do more. But if you really want to become fluent, you’ll have to do more.

Total Immersion

If you talk to someone who’s fluent in a second language, most of them will point to a time where they spent a significant amount of time studying and conversing in the language of interest. He may have spent months or years working or traveling in the country. Maybe he spent several months in a study abroad program. The key is that he was forced to use the language every day, practicing and learning over a long period of time.

To really get good at any programming language, you need to do the same. It’s one thing to copy some snippets from the internet. It’s quite another to construct something out a blank canvas. You can read books and articles on the language or even take a course, but ultimately you need to find a way to immerse yourself in the language. Find a reasonably complex project–something more than a glorified “Hello World” program–and write the whole thing in that language. This will force you to use it on a daily basis, learn it’s idiosyncrasies, and develop a better understanding of how to “converse” in that language.

Dream in Code

I’ve been told that once you speak a language long enough, you start to think in that language, sometimes even dream in that language. At this point, you are truly bilingual, able to converse with native speakers without difficulty. You have reached the level of fluency that you spend more time thinking about what to say, rather than the mechanics of how to say it.

When truly learn a programming language, it’s much the same. You no longer have to think about syntax, built-in libraries, and project structure. There is no longer a need to translate, in your head, from your first language to the second. You can express the solution to a problem in the terms that make sense for the target language.

Worth the Effort

Learning that second, third, fourth language is worth the effort. Many times, languages are related, making it easier. Just as many of the romance languages of Europe tend to have many commonalities, programming languages share many traits. Copy and paste to start, get familiar with the language, then take the plunge and immerse yourself in a project that uses the language. By the time you’re done, you’ll be dreaming in code and ready to tackle the next language.

Question: What tips or techniques do you use to learn a new programming language?