Becoming a Polyglot Programmer

[I’m referring to being a programmer who is comfortable using several languages here, rather than a system built with several different programming languages.]

I spend most of my time programming in only two languages: Perl and JavaScript. I often feel I’d like to learn a few more, or at least sample a few more. I often find this hard to do however as step-by-step beginner tutorials don’t rub off on me too well, and taking on a full side-project can be overkill when all you want to do is try out a language (I’m slowing becoming more and more familiar with the Python universe because of one; not necessarily a bad thing!).

But I’ve recently discovered a way to try new languages which involves solving actual problems: Project Euler contains many small yet challenging mathematical problems, in a form similar to many online coding contests (like Google CodeJam). You are given a problem, have to submit the answer, and are immediately told if you are correct. This is generally good for keeping your problem solving skills sharp, but the real benefit for me is that I can attempt to solve each problem with a different language! So that’s what I’m going to try…

Why is this a good thing to do? Once you’ve learned one or two decent general-purpose languages, why bother to know about others? Well, I see a few advantages:

  • Becoming familiar with other languages can cause you to look at problems a little differently, and to look at the problems you solve with the language you are most familiar with a little differently also. You may find that a common approach used in a newly sampled language fits well with a problem you are tackling in your day job. A paradigm shift (OO –> functional or asynchronous event loops) may surprise you when you learn what is possible with altogether new ways of approaching problems.
  • Maybe there’s a language out there that’s just right for you. The way the syntax and external resources have been designed seems to go well with your way of thinking, and maybe its community resonates well with your personality. Maybe you’d be more productive using it. And maybe you’ll never discover it.
  • If you decide to learn a new stack by say writing a Rails app, you may find you don’t do a lot of work with the underlying language. Your learning will lack a solid foundation, leaving you confused in places and with gaps in your understanding.
  • When job offers come up you’ll probably know something about the language the company is working with, and you’ll have a base to continue to learn from (if you get the job that is!).
  • It’s just good fun!

I’ve just started this, and so far have solved four problems in three languages (Perl, Python, Ruby). I’ll probably solve two or three problems before moving onto a fourth, and will deliberately make my programs reasonably well designed (by using OOP when available, passing arguments via the command line rather than hard-coding them) in an attempt to get more exposure to each language.

I tend to find I actually learn something when I do things this way. When I have a problem to solve, I go out and look for the syntax necessary to implement my algorithm. When I’ve completed a problem, I plan to go off and read over the documentation of the language I used. I find that once I have a reference point (the work I just did solving the problem) I can take in the documentation much more easily. If I really liked the language, I could then decide to learn further by taking on a side-project (e.g. if I liked Ruby perhaps I could build a Rails web-app).

Hopefully in a few months time I’ll be familiar with quite a few new programming languages, and maybe you will be too!