“If we’d written this in Python we’d be done by now”
I’d never really had a ‘programming language of choice’. My first languages were SML and C; I wrote my final year project at University (badly) in Prolog; my first paying job was coding in Progress 4GL and I finally ended up writing predominantly in Java.
Then I encountered Perl. It was interpreted, meaning no compilation (and no typing public static void main(String args) just to get things going) and thanks to CPAN it felt like there was nothing I couldn’t get done. I wrote for fun (my first public project being a program to submit—scrobble, that is—tracks from my old Cowon media player to my Last.fm account; oh, I had high ambitions). But Perl is a great language for doing things in; it’s not pleasant for having done anything. Much like the morning after one too many inebriants, looking at any Perl script I ever wrote is like nursing a terrible hangover: utterly horrid and entirely my own fault.
A few months ago (after checking my calendar, actually close to 8 months ago; I have an 8 week old daughter—my sense of time is a little off; I digress…) I was standing in the lobby of the Internet Archive, ice cream sandwich in one hand, root beer in the other (when in Rome…) chatting with colleagues about the seemingly ubiquitous habit of rewriting tools in Python. Several major projects had recently undergone an overhaul from Java to Python and while the results largely spoke for themselves, and yours truly was thoroughly in the “I heart Python” camp, the question was bluntly asked: why do you like Python?
After some to-ing, fro-ing and hand-waving (and supplementing of our erstwhile snacks) we agreed on two major points:
- For whatever reason, Python has inspired a lot of very cool people to do some very groovy things (cool people who don’t use words like “groovy”, or ” cool” for that matter).
- Python is a language for: Getting. Shit. Done.
Although Python has a powerful libraries for processing large datasets (and we were talking BIG data in my former milieu), maintained by an active, broad and invariably ingenious community, those are simply symptoms of something intrinsic in the language that prompts its adherents in their fecund endeavours:
- The fundamentals are simple.
- It’s fun.
I think the latter point is largely dependent on the first (or possibly resulting from origin of the language’s name—who knows? Go look it up) but I think it simply comes down to that. Whether it’s the versatile raw types, the syntax, those little axioms around which all this code is constructed, they’re all beautifully simple. Hell, they teach children to program hardware using it.
Unlike other languages (see: Perl, the “Swiss-Army” chainsaw of languages), Python is antithetical to the idea that there’s “more than one way to do it”. No: there’s only one right way to do it; need to open a file on disk? There’s a function called open(). Need to open a file over HTTP GET? Use the (pretty much de facto standard) requests library—it has a function called get(). Need to do the same things in Java? InputStream, InputStreamReader, Connection (not to mention public static void main(String args))…good times.
There’s a great quote regarding the readability of one’s code: “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” Invariably (and much to their—certainly to my—chagrin) any developer will spend more time reading code than writing it; any language which guides you into writing readable code (Ctrl+Shift+f in Eclipse—how hard is it?) drastically reduces complexity of your code and is going to involve infinitely fewer of those head-scratching moments a few years down the line (and potentially stop you reaching for the hockey-mask and machete…).
But if we wrote this in Python, would we be done by now? For me, it largely comes down to that second point: it’s fun. There might be a problem with which I have to wrestle, but I don’t have to fight the language while I’m doing it.
We Love Data
Want to know more?
Drop us a line – we’re always happy
to chat – we promise we’ll keep the
geek speak to a minimum (unless
that’s your bag in which case we’ll