UVTC's Blog


There’s an aspect of Perl 5 that I find particularly interesting. Perl 5 has seen it’s share of popularity over the years. Reasons for this might include: its large, friendly, and supportive community, its mature tools, the vast CPAN, and having Larry at the steering wheel. It’s also been noted that Perl 5 happened to be in the right place at the right time (the dot-com boom).

I think there’s more to the story though. Perl 5 has a lot of well-known warts. For example, there’s no real standard built-in object system. Likewise for exceptions and named subroutine arguments. It’s also got some ugly syntax (for example, de-referencing deeply nested data structures). It’s sometimes difficult to know what a particular operator will do in a given context (for example, regex matches and search/replace operations, with and without the /g flag, in scalar vs. list context). Just ask online what people don’t like about Perl 5 and you’ll get an earful.

Yet Perl 5 survives.

It’s amazing, really. Here’s venerable old Perl 5. With all its warts and missing features. With detractors howling about how awful, unreadable, and unmaintainable Perl 5 code is. With the peanut gallery complaining about how it’s dead and how it’s due to be replaced with Perl 6. One of its own faqs jokes about how the work of parsing it “is distributed between yacc, the lexer, smoke and mirrors”. Here’s Perl 5, strenuously maintaining backward compatibility while at the same time competing with very popular and modern languages like Python and Ruby, and yet Perl 5 survives. It’s doing just fine, in fact.

How is this possible?

In the final analysis, I think the reasons it survives are:

  1. It’s got really great documentation. It’s docs are particularly special because (1) they almost invariably come with example code right at the top (the SYNOPSIS section), and (2) because they are split up into useful man pages and accessible via the perldoc tool.

  2. It’s fairly easy to learn. (Larry has talked about having “easy on-ramps”, and noted that “easy things should be easy”.)

  3. It’s usable. Perl 5 puts useful features within easy reach. For example, built-in regexes, file tests, and well-named top-level functions such as substr, splice, chomp, grep, join, etc.

  4. The friendly, helpful, non-judgemental community (which is actively fostered). Just ask on, say, Perlmonks how to do some crazy task. Instead of being told not to do that, or that your way is not the right way to do what you want, or instead of being asked if you’ve forgotten your medication, you’ll very likely instead get something like, “Wow, sounds crazy! Anyhow, here’s how you might do it … Hope that helps.”

That’s it. That’s why I think Perl 5 still works for people and successfully competes for mindshare among other popular comparable languages. In spite of its flaws, shortcomings, and eccentricities. It’s not directly because of the CPAN, or the large size of the community, or all the unit tests, or the amazing and mature tools – I think those things are results of the 4 traits listed above.

On Perl 6

I’d add that I hope Perl 6 is able to replicate the 4 traits listed above. It looks like they’ve got items 3 and 4 all set. Not sure about item #2. However, after having poked around a bit, I’m disappointed that it appears item 1 is not there. Perl 6 has no perldocs. It’s got a book under development, design documents, various examples are available, there’s blog posts (and also these to name just 2 blogs), presentations, advent calendars (2010, 2009), screencasts, a poster, and a cheatsheet, but no easily-digestible bottom-up user documentation. No perldocs.

The general Perl 6 wisdom seems to be that you need users’ feedback in order to hone the language design and implementation. Perhaps the perldocs can come later? – I don’t think that’s optimal. My hunch is that you first need solid user docs before you can get an appreciable number of users to provide a useful amount of feedback.

As I see it, lack of perl6docs is Perl 6’s major shortcoming right now. Perhaps someone is working on perldocs in stealth mode. Perhaps the Perl 6 team is first completing additional important technical pieces before embarking on writing the perldocs. Perhaps they’re waiting for a champion. I don’t know. But I don’t see Perl 6 achieving escape velocity without real down-to-earth Perl-5-style perldocs.