Archive for January 5th, 2007

January 5th, 2007

Revising my Opinion of Python

by Tim Cull

So more than 5 years ago when I worked at i2 Technologies, I was on a team developing a client-server rich client application that was written with a Frankenstein combination of Python and Java. The whole experience left me with an especially bitter taste in my mouth for python.

Fast forward 5 years and now I’m using Python again. We’ve got an application that is using a distributed object cache (Tangosol Coherence) instead of a relational database to store data. We needed a client for ad-hoc query/update/delete on the cache and since no such client existed we needed to write one.

A scripting language is an obvious choice for this, and since it needs to be one based on Java (Coherence is Java-based) our choices were basically JRuby, Jython and maybe Groovy.

What I really wanted to use was JRuby, but Coherence does a few weird things with static fields and the equals() method that make using JRuby basically impossible. So grudgingly I’m using Jython.

And it’s awesome. This, I think, is a perfect use of Python. I’ve got lambda functions flying all over the place, dynamic typing is really useful, and manipulating lists is half the code. It’s all stuff that, the first time I saw it, I thought, “hmm, yeah that’s cool I guess, but what would you ever use it for? Why do people drool over lambda functions?” Well, now I know.

Just more evidence that finding the right tool for the right job is half the battle. I’ve now got a complete command-line client that does selects, update and deletes, and it’s only 100 lines of code long.