Why Perl 5.10 is Modern and Perl 5.8.9 is Legacy


In discussions on PerlMonks and elsewhere about Modern::Perl, the implicit question has come up. Why does Modern::Perl refuse to install on any Perl with a version less than 5.10?

First, I offer two caveats. If you're reading this, you're probably capable of deciding for yourself which modern Perl features you want to use where. You're likely a willing CPAN user, if not a CPAN contributor. You almost certainly can explain what the strict and warnings pragmas do, and why you don't need to use diagnostics (even if you recommend that novice users do). I realize that not every reader fits that profile, but it's easy to imagine that at least nine out of ten people who read this do.

Thus, to the tens of thousands of experienced and careful Perl programmers in the world, I have some good and bad news. Modern::Perl is not for you; it will do you very little good. It's for people who don't know how to get the benefits it provides in the standard a la carte fashion. It's a buffet ticket of modern Perl goodness.

Second, any other CPAN distribution which depends on Modern::Perl and doesn't explicitly mark a perl dependency on at least Perl 5.10 is in a grave state of sin and error and deserves quick bug reports filed. You can cite me as an authority on this.

Hopefully the other six and a half billion people in the world who aren't experienced Perl programmers who proudly use and reuse and create CPAN distributions didn't mind that short digression.

There are several reasons why I consider Perl 5.8.x as "legacy", at least for the purposes of Modern::Perl. Take your pick of a few.

First, 5.8.9 is the last substantive release in the Perl 5.8.x series. It's reached the end of its lifetime. There will be no bugfixes, except perhaps for security errors. That codebase has no future.

Second, Perl 5.10.1 is on the way. I realize that the CPAN calls Perl 5.10 a "testing" release, but that's more a nomenclature problem than anything else. Perl 5 has the largest regression test suite of any modern dynamic language I've looked at -- especially when you consider that the comprehensive test suites of a good portion of the CPAN run regularly against bleadperl.

Third, Perl 5.10 fixes an amazing number of bugs and misfeatures, especially regular expression engine reentrancy problems and closure bindings. Yes, generally only advanced code exposes these problems, but they were very difficult to identify and debug.

Fourth, Perl 5.10 adds a handful of very convenient features which address common error conditions. For example, the defined-or construct is an improvement over the long-lived true-or construct used to assign default values to a variable. The problem with ||= is that it overwrites any value which resolves to false in a boolean context. That seems okay, but there's a semi-predicate problem if 0 or an empty string are legitimate values.

Another lovely feature is being able to lexicalize the universal pronoun $_. Certain looping constructs localize it. Others don't. This is often a source of subtle bugs.

Fifth, Perl 5.10 backports several wonderful features from Perl 6. The given/when construct simplifies code immensely. So do named captures in regular expressions -- and they improve readability too.

As silly as it sounds, I use say all the time. All it does is append a newline to the final string printed, but it's incredibly useful.

Sixth, Perl 5.10 improves some warnings. In particular, I'd upgrade to 5.10 for only one warning. Previous versions of Perl warned when you interpolate or concatenate a variable containing the undefined value. That's handy, but 5.10 goes further by telling you which variable contains the undefined value.

That list is not exhaustive -- I like some of the memory usage improvements too, but regular users are less likely to see those.

Maybe you don't need any of these features. Maybe you're perfectly happy with Perl as it existed in version 5.005_3 (though how can you not love lexical filehandles?). That's fine.

Note that almost none of these features are available in Perl 5.8.x (though you can get your own say(), and there's a patch available to add defined-or if you want to compile your own Perl). I can't imagine not being able to use these features, and I don't want to consider how to teach Perl to novices without some of them.


chromatic, you've defiantly implied it but you never come out and state it, if Modern::Perl is to be a foundation to smooth the path in to Perl, then users, by default, will install the "newest" release. Even though 5.8.9 was released after 5.10.0, the version numbers indicate to install 5.10.

Modern Perl is a good idea!

For agitation (and for fun) I did it http://rostovondon.pm.org/modernperl/

Modern Perl: The Book

cover image for Modern Perl: the book

The best Perl Programmers read Modern Perl: The Book.

affiliated with ModernPerl.net



About this Entry

This page contains a single entry by chromatic published on January 29, 2009 3:19 PM.

Managing Complexity with Procedures was the previous entry in this blog.

Eliminating Messy Code with Sentences and Paragraphs is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Sponsored by Blender Recipe Reviews and the Trendshare how to invest guide

Powered by the Perl programming language

what is programming?