In association with heise online

"The New Perl Enlightenment"

CPAN is also where you'll find evidence of what one phrase maker has called "The New Perl Enlightenment" - a loose movement of CPAN module authors who are committed to building a suite of a high quality tools and libraries for developing professional, maintainable software, in Perl.

If we just start by looking at developer support modules, there's a comprehensive set of modules supporting test driven design, though if you're expecting xUnit style testing you'll be slightly surprised - Perl's family of testing modules and the style of reporting pre-date the widespread adoptation of xUnit - but Test::Class by Adrian Howard should fill your needs neatly. You'll also find modules for laying out the boilerplate bits and pieces for a new project (Module::Starter, by Andy Lester, Ricardo Signes and C.J. Adams-Collier); a reasonably accurate profiler (Devel::NYTProf, by Adam Kaplan, Tim Bunce and Steve Peters); a better recursive grep utility (ack, by Andy Lester) that knows how to ignore the uninteresting bits when you're just looking for code; and a module (Perl::Critic, by Jeffrey Ryan Thalhammer) which walks over your code and finds places where it doesn't conform to good style guidelines.

A particular favourite module of mine in this space is an old one, Dave Rolsky's DateTime family of classes, which took on the challenge of doing the Right Thing with dates, times, time zones, leap years, leap seconds and all the other gubbins associated with the calendar. It's a bigger problem than you probably realised. Telling the time is a human thing, and different humans around the world have different ideas about what the natural and obvious way of dealing it should be. And they've changed their minds about that over the centuries. Even something as purportedly simple as a time zone designation is fraught with ambiguity. Dave did the Perl community a great service when he bundled up all the nastiness, got the calculations right and released the results to CPAN. It's one of the modules you miss when you're coding in other languages.

More recently, we've seen the rise of Moose which does object orientation (OO) right. Perl 5's OO support has the nature of a kit of parts. You get the bare minimum you need to allow to roll your own object/class system using almost anything you like for your underlying data structure. Damian Conway wrote an excellent book (Object Oriented Perl) for Manning, covering pretty much all the methods for doing OO then known. Not long after that book was published, someone thought of a new one.

Moose is an example of the Perl 6 dividend. The author, Stevan Little, started out working on Class::MOP, a Perl 5 implementation of the proposed Perl 6 meta object protocol (Perl 6 will be getting first class objects, the meta object protocol is a low level description of how they work). Once that was done, Stevan used it to implement Moose, which is a high level declarative mechanism for defining classes in Perl 5. It steals ideas from everywhere, but mostly from the Common Lisp Object System. The result is just lovely. The basic system is neat and its malleability has spawned a huge family of extensions (mostly to be found in the MooseX::* family of modules on CPAN).

There are issues with start-up speed (which are being worked on), but as a rule of thumb, if you're starting work on a new Perl project and you're planning to write in an OO style, then you should be using Moose.

Moose is a better mousetrap, and it's spreading across CPAN as key modules get redone with Moose underpinnings. The Catalyst web framework, for example, is in the process of being moved over to Moose, with the developers reporting 'leaner and more maintainable code' as a result, so is Matt Trout's DBIx::Class, which has become the de facto standard for object relational mapping.

Next: Of frameworks and the future

Print Version | Permalink: http://h-online.com/-746527
  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit