In computer science, you have to learn new languages and frameworks on a regular basis, because the field changes so quickly. I’ve learned my share of languages over the years, well over a dozen last time i counted (most of which i don’t use anymore). Perl was the last one that i really invested time in at BBN, and it was my main language for scripting and data processing for the last half dozen years or so (as a manager, this was the only kind of programming i could get away with :-)).

A couple of years ago, i made the decision that my next language would be Python. My reasoning was based on a pretty simple kind of social networking: over and over, the bloggers i read, colleagues i respected, and projects of interest i discovered kept talking about Python. I figured if this many smart people were using it, there must be a good reason. When i started work at Logos this year, i had more time to focus on programming, and finally got to make good on my intention. I haven’t been sorry, and having done a lot of Python coding over the last 6 months (the only way you really learn a language), i’m really loving the language.

Here are some of the things i’m finding that are great about Python:

  • Interactive evaluation: how many times have you embedded print statements inside your Perl code so you can figure out what’s going on? Python lets you short-circuit that because you can evaluate expressions directly, inspect the results, and work on it until you get it right. It has the side-benefit of encouraging modularization of your code, simply because that makes it easier to test interactively. For me, interactive evaluation provides an enormous productivity boost.
  • List processing: I’m not embarassed to admit that i still think Lisp is one of the best languages i’ve ever coded in. When i did a little recreational programming last year, i went back to my Lisp roots, because some problems just cry out for list-based solutions. Perl has lists, lists of lists, etc. but there’s just enough friction in working with them that it always feels hard to me. Python brings back a rich list-based environment with mapping, filtering, and other useful features. Though some people find lambda functions intimidating (the name doesn’t help),they’re a very powerful feature. Python also has set operations (intersection, union, etc.) which are very helpful for data cleanup.
  • Introspection: you can ask the environment what objects it knows about, and you can ask an object what its methods and attributes are. This enables powerful kinds of meta-programming capabilities.
  • Django, a web application framework (like the popular Ruby on Rails) that makes it very easy to build rich, data-driven, web-based systems. I’ve been using Django to build a thesaurus development interface for in-house use, and i strongly recommend it (i hope to start a side project soon using Django for publishing genealogy information).

I’m not trolling for flamewars here (i’ve managed to do so inadvertently in the past), and i still like Perl. But from now on, i’m a Python guy.
Other reading:

  • JoelOnSoftware has a characteristically insightful post about why the question “what’s the best language to use?” isn’t really meaningful. He points out the value of the language’s ecosystem as a key criteria: that was one reason Python made it to the top of my list.
  • I’ve been playing with the Natural Language Toolkit, which is written in Python. It’s still in flux, but has a lot of interesting capabilities, including a good WordNet interface.