pozorvlak ([info]pozorvlak) wrote,
@ 2007-03-13 13:08:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
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.

  1. 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.
  2. Lexical scope is not the default.
  3. File::Find's interface is terrible: almost as bad as that of find(1), which is my least favourite Unix utility.
  4. Parse::RecDescent isn't in the standard distribution. Actually, the choice of bundled modules is another thing the snakeheads do better, I think.
  5. 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).
  6. 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!
  7. Lack of named argument parameters, other than by explicitly deconstructing @_. No biggie, I suppose, but it irks me.
  8. map and grep don't accept coderefs. Or rather, they do:
    $f = sub { $_[0] + 3 }; print map $f, 0 .. 3
    CODE(0x8167900)CODE(0x8167900)CODE(0x8167900)CODE(0x8167900)
    Bugger. What I meant, of course, was
    $f = sub { $_[0] + 3 }; print map $f->($_), 0 .. 3
    3456
    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.
  9. 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.
  10. 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, [info]paddy3118!


(Post a new comment)


[info]mi_guida
2007-03-13 02:21 pm UTC (link)
Ooohh... have decided I like "beware of the geek" posts. They're like listening to music in a foreign language, they just pleasantly wash over me.

(Reply to this)


(Anonymous)
2007-03-13 11:17 pm UTC (link)
To be fair, you have to understand the language well enough to have a valid complaint. You seem to simply not understand some things. So what if File::Find has a bad interface? That's not something to hate about the langauge! Just use a different file finding module. Parse::RecDescent isn't in the core distro! Oh no! Again, nothing to do with Perl as a language. Don't understand that $i[12] is the thirteenth element of @i, and has a $ out front because it's a single element? It's not that hard to teach if you understand it.

The trick is the understand it and still hate it. Until you can do that, you aren't ready to have an informed opinion.

(Reply to this)(Thread)


[info]pozorvlak
2007-03-13 11:40 pm UTC (link)
Your only valid criticism there is the one about $i[12] - you've got me there, it is the thirteenth element. And yes, I do understand why it has a $ in front, as you might have gleaned from my beginning my sentence with "I understand why...". I can explain that $ means "this" and @ means "those" and that it reflects natural language until I'm blue in the face, but that doesn't stop almost everyone from reacting with "that's totally bogus, I'm going to learn a sane language". Which is a pity, because insane languages are much more fun.

I was going to write something long about the relationship between modules (especially standard modules) and the core language, but I can't be arsed, as you're just being an unpleasant troll and don't deserve a thoughtful answer (whoever you are).

(Reply to this)(Parent)(Thread)

Perl Array indices start at ...
[info]paddy3118
2007-03-14 04:51 pm UTC (link)
Perl array indices, out of the box, start at zero but they can be changed to start at one. - Which is a great way to pull the rug out from under any maintenance guy.

- Paddy.

(Reply to this)(Parent)(Thread)

Re: Perl Array indices start at ...
[info]pozorvlak
2007-03-14 11:18 pm UTC (link)
You know, it should have been obvious to me that it would be possible to do that, but somehow I'd never thought of it. Looking through man perlvar, I see it's $[ you need to change, but "Its use is highly discouraged" :-)

As I've said before, Perl is a language that believes in giving you enough rope to hang yourself, then another few yards just to be on the safe side.

(Reply to this)(Parent)(Thread)

Re: Perl Array indices start at ...
[info]johnckirk
2007-03-15 12:10 am UTC (link)
VB was like that (pre .NET) - you could either declare an array with lower and upper bounds or you could leave the lower bound implicit. By default it would be 1, but you could change that default to 0 at module level. My policy was always to declare both bounds, to avoid that kind of trap. (In .NET, the lower bound is always zero.)

More generally, I can't think of anything I really hate about the latest version, partly because I'm still relatively new to it so I'm aware that there's a lot I don't know.

(Reply to this)(Parent)


(Anonymous)
2007-03-15 01:46 pm UTC (link)
I just want to say that I am an entirely different "anonymous"! I know nothing about computer programming and I would never post a rather rude comment like that!

(Reply to this)(Parent)(Thread)


[info]pozorvlak
2007-03-15 02:27 pm UTC (link)
Er, that's good... so, not all anonymous commenters are trolls, hurrah! Or something.

I always find it rather odd when I get anonymous comments, or comments from people I don't know. How do they find me?

(Reply to this)(Parent)(Thread)


[info]nou
2007-03-15 02:36 pm UTC (link)
People have found me via livejournal's friendsfriends page, or via an interests search (in fact, an interesting person popped up just the other day, on this post). There's no reason your first anonymous commenter has to be someone without a livejournal account.

(Oh, and your point #3 is actually the same as point #4, given the existence of File::Find::Rule.)

(Reply to this)(Parent)(Thread)


[info]pozorvlak
2007-03-15 02:57 pm UTC (link)
*reads*

"Knowledge gardening", eh? Cool...

Yes, there's some redundancy in the table, and I could certainly have combined #3 and #4 (and #6, to some extent) into "choice of standard modules could be better". But that's just something I find mildly irritating, whereas those two-and-a-bit points are the specific instances that really bug me :-)

*installs File::Find::Rule on this box*

(Reply to this)(Parent)(Thread)


[info]petdance
2008-05-04 02:14 pm UTC (link)
Also take a look at File::Next.

(Reply to this)(Parent)(Thread)


[info]pozorvlak
2008-05-04 07:42 pm UTC (link)
Looks good! Thanks!

(Reply to this)(Parent)

Find is great
[info]aftnn.org
2007-03-16 10:56 am UTC (link)
What are you talking about? Find is a great utility! I've wiled away many many happy hours crafting 300-character commands with find at their heart.

BTW, your ten things I hate about Perl is pretty much bang on, not sure how I'd order them (I'm assuming this is `select long_winded_explanation from perl_failings order by thought_of_time`).

So why are you still using it so much?

(Reply to this)(Thread)

Re: Find is great
[info]pozorvlak
2007-03-16 11:25 am UTC (link)
find is very powerful, certainly (and uses some very clever tricks to make searching faster), but I've always found it a total pain in the ass to use for anything nontrivial. It doesn't help that half the copies of find I've used want the path after the expression, and the other half want it the other way around, and I can never remember which applies on any given machine :-(

Select explanation from perl_failings order by thought_of_time is pretty much what I did. But that kinda works, because I'd think of the most annoying things first.

Why am I still using Perl so much? Well, three reasons:
  1. As I said in my penultimate paragraph, I still really like it, despite the things above. There are some things that I think Perl really gets right - mutable typing, the ease of using regexes, and CPAN, to name but three.
  2. Maybe I'd like Python or Ruby better if I gave them a serious try (Ruby looks especially interesting), but right now all my language-learning energy's going into Haskell.
  3. I don't, actually, use Perl all that much any more (and I can feel my fluency slipping as a result). These days, it's pretty much just the occasional one-liner for system administration botheration, text munging or simple calculations, and Perl's perfect for that.

(Reply to this)(Parent)(Thread)

Re: Find is great
(Anonymous)
2008-04-28 02:48 pm UTC (link)
Dont give ruby a try unless you plan to stop using perl. ;)

Now that I know Ruby too, python is less appealing than Haskell (I am not dissing python at all, i like python more than perl, but Haskell is simply a lot more interesting than python IMO after knowing ruby)

(Reply to this)(Parent)

Bad Press?
(Anonymous)
2008-05-04 06:56 pm UTC (link)
I am continually surprised that Perl has such a bad press

With dicks like you, complaining about things that are properly built, just because you don't understand them, what other kind of press were you expecting?

It's your fault, really.

(Reply to this)(Thread)

Re: Bad Press?
[info]pozorvlak
2008-05-04 07:44 pm UTC (link)
1) You miss the point of the exercise. Read brian d. foy's post.
2) Do you understand everything about Perl? Really? Absolutely everything?
3) You're the one being a dick here. Piss off.

(Reply to this)(Parent)

Some suggestions
[info]yuval_kogman
2008-05-06 09:10 pm UTC (link)
Regarding OO: Moose establishes a much more solid foundation than the various accessor generators out there, i think you should take a look.

Data::Alias can alleviate some of your issues with references by making them unnecessary in certain cases.

My favourite File::Find replacement is Path::Class's recurse at the moment.

Lastly, re laziness Data::Thunk is almost a sane thunk implementation (this is a plug ;-)

Python's core libs are indeed much better. I think they have less fear of breaking compat, a more rigorous quality control process for that stuff, and less accumilated cruft. Kinda sad, but hey, we do have the CPAN

Cheers

(Reply to this)(Thread)

Re: Some suggestions
[info]pozorvlak
2008-05-06 10:25 pm UTC (link)
Great, thanks! I'll have a look at all of those. It's great that so many people have offered helpful suggestions here.

I read recently about the changes they're making to the Python core libs for Py3K - they've clearly put a lot of effort and thought in. But they started with a pretty complete and orthogonal set, I think.

(Reply to this)(Parent)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…