Saturday, November 13, 2010

I reject you, Perl

So, I'm piddling with some tiny shell script, and decide to substitute in some perl instead.
'cause, I'm just a sucker for a language that looks like it was designed by a thousand drunken monkeys.

Well, so, anyway, I find out that this doesn't work as I'd expect:
perl -lne 'print $ARGV[0]' filename

When called with -e argument, $ARVG[0] doesn't equal the first argument to the script. Really?

It is supposed to be an array of command line arguments. Unlike every other language that uses an argv convention, Perl doesn't include the name of the command in the array, but I digress.

When you run Perl with the -e argument, it magically changes.

The rationalization for this design feature are no doubt tucked into some dusty corner of a list server, but who really cares?  It is different in a way that seems gratuitous and more than a little astonishing, so even though it was an ancient decision, it still seems rather stupid.

Everything needed could be done in shell. Anyway, other smarter and smaller languages exist. I have options.

So when I'm stupid enough to bother with a massively bloated interpreted language like Perl, and it decides to astonish me with a really poor implementation design decision and unexpected behavior, rather than blame myself and accommodate the idiocy of the language, I reject it.

No comments: