Why Perl is not my favorite language

August 3, 2005

I could talk about aesthetics; I could talk about line noise and readability; but for me it ultimately comes down to one thing: data structures.

Namely, I find it very hard to write perl code of any depth without running headlong into the fact that Perl's 'collection' types (arrays and hashes) can't contain themselves. All they can contain is scalars (strings, numbers, and references).

For example, recently I was writing a program to mass-query the SBL DNS blocklist and wanted to stick a caching layer in so that I'd only look up a given IP address once. The natural way to do that is with a hash, indexed by the IP address. Except that an IP address can be in more than one SBL record, so the natural representation for the result is an array, which can't be put in the hash.

Perl fans will retort that I can just use references. I could write a long answer, but I'll just go with the short one: 'if I wanted to use pointers, I'd write C'.

That's what references are: sticky pointers. And like all forms of pointers, they're an implementation detail. Low level languages like C are all about the implementation details, but I dislike high-level languages that make me think about them very often. (Implementation details are a distraction; every bit of effort you have to spend on them is effort you are not spending on the real problem.)

I could write more than small things in Perl. It's not that the language is incapable. It's just that it's annoyingly distracting, and I'd generally rather not bother if I have the choice.

Written on 03 August 2005.
« Multilevel list comprehensions in Python
Keep your hands off my font size »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed Aug 3 01:39:22 2005
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.