| pozorvlak ( @ 2007-03-13 13:08:00 |
| Entry tags: | beware the geek, computers, hate, ideas, perl, programming, rants |
Ten things I hate about Perl
brian d. foy says that you can't be an effective advocate for a language unless you can think of five things that you hate about it off the top of your head, the reason being that if you can't, then you don't know enough about the language to advocate it effectively. So, just to go one (or five) better, here are ten things I hate about Perl.
- References. I don't have anything like as many problems with the syntax (which is baroque, even by Perl standards) as I used to, but I still don't like it. And really, why do we even have references? Some things returning/accepting listrefs and some things returning/accepting lists is a fertile source of pain, and the whole business is unpleasantly typeful. And yes, I know that making deeply-nested data structures mildly painful to use helps to avoid Lisp Programmer's Disease, but is the cure really better than the disease in this case? Overall, I think Python handles this a lot better.
- Lexical scope is not the default.
- File::Find's interface is terrible: almost as bad as that of find(1), which is my least favourite Unix utility.
- Parse::RecDescent isn't in the standard distribution. Actually, the choice of bundled modules is another thing the snakeheads do better, I think.
- Sigils. I understand why the 12th* (edit: 13th - thanks, anonymous troll!*) element of @i is $i[12], but it makes the language hard to teach - lots of people who might otherwise get a lot out of the language think "What? That's totally bogus!" and stop there. And having four separate namespaces, distinguished by the initial characters of symbols, is unpleasantly Fortranish (Fortranian? Fortroid? Ah, that's the one).
- OO requires either writing unnecessary boilerplate (all the bless $self, $class business) or using one of the various CPAN modules out there to make this easier. Yes, it's great that the guts of the OO mechanism are exposed, and that you can write such modules, but it would be great if there were an easier, standard way of just writing a class!
- Lack of named argument parameters, other than by explicitly deconstructing @_. No biggie, I suppose, but it irks me.
- map and grep don't accept coderefs. Or rather, they do:
Bugger. What I meant, of course, was$f = sub { $_[0] + 3 }; print map $f, 0 .. 3 CODE(0x8167900)CODE(0x8167900)CODE(0x8167900)CODE(0x8167900)
Note that reference syntax there. What's really going on is that map and grep take blocks or expressions, not functions. map chr, 70 .. 73 works, but that's because if chr isn't given any arguments it defaults to $_. I suppose this makes sense, but it's not how I think of map, and it's not how it works in most languages. Maybe I've been spending too much time with functional languages.$f = sub { $_[0] + 3 }; print map $f->($_), 0 .. 3 3456 - No laziness. I have been spending too much time with functional languages. Of course, you can get many of the benefits of laziness with iterators, but it's more work. Note also that the <> operator is effectively lazy input-reading. Unless you want it not to be.
- Perl 6 (which promises to fix most of the complaints above) is taking so long to arrive! :-(
This is not to say that I hate Perl: far from it. I think it's a wonderful, fun language, with a great community around it, producing some insanely cool software (CPAN might be considered the world's premier laboratory for module and language-extension design). I am continually surprised that Perl has such a bad press, and gets such short shrift from the language-design community. You might expect that a language that breaks almost every accepted precept of language design would simply be a bad language, and no fun at all to use. Yet Perl does this, and has a fanatical community of users, some of them truly excellent hackers. This, it seems to me, is a datum point of enormous importance.
But anyway, I'd like to ask this question to the hackers reading this. What five things do you hate most about your favourite language?
* Unless you've set $[ to 1 - thanks,