A couple of days ago I started learning python. As I go through the experience of learning another language I want to take a step back and talk about how a person who has siginificant experience in other programming languages might approach learning a new language.

Like most folks in the community I too started out serious development with Java and over the years learnt and unlearnt several techniques with this language. And as a consequence the way I write code today is an outcome of several influences I have had and preferences/styles I have ended up cultivating. For example my increased affinity for unit testing. I tend to follow it very religiously when it comes to doing something non trivial. In fact even when doing something trivial instead of a sysout I prefer an assert statement.

When encountered with a new language, what approach should a seasoned programmer use be productive asap?
IMO what seems reasonable is taking oneself through a breadth first tour of the language -

  • Starting with understanding the typing/type system (strong/weak, static/dynamic) style of the language.Play with the shell if any. Use it heavily to check “if this code works”
  • Understand how libraries are managed (installed/uninstalled/imported into your code). Explore availability of package managers etc. And as far as libraries themselves go my preference is to start with simple IO followed by some network IO and then some XML parsing and database connectivity.
  • Start with your first program doing something non trivial. For example it could be parsing an rss feed. This can turn into an exhaustive exercise. Sucessfully finishing this task means you have learnt how to use an xml parsing library, designed a set of collaborating classes/functions/modules or whatever constructs the language supports and have tested it. In this way you even learnt how to unit test your programs using XUnit for that language.

One another aspect that I have found worth studying is the meta programming and reflection constructs that the language might have to offer. This often helps you write code that is quite terse and often helps you acquire a higer level of expertise/mastery of the language. Though I reserve this experimentation for a later stage in the learning process I think its necessary to do it and more importantly try it out on your starter program you have built thus far.

The objective of this exercise is to get to a stage where you can be nearly as productive as you are currently in your “technical mother tongue”. While this is one of the ways I would love to know if people have tried other approaches. In particular when you are learning a language that does not support conventional paradigms like OO (like Scheme,Prolog etc) will this approach work?
Arguably if one started with a language like Scheme learning other languages will be easier but unfortunately not every CS curriculum/entry level training program encourages it.