##CONTINUE##
Perl's current standing is like that of JavaScript a few years ago. JavaScript was perceived as a ghastly, hacky language, which was so awful that one had to hold ones nose to program in it. With the rise of excellent JavaScript frameworks like Jquery, YUI, MooTools and Dojo and the publication of Douglas Crockford's JavaScript: The Good Parts, people are realising that it's actually a really nice language with occasional quirks.
Perl began life as a language for systems administration, probably because its creator Larry Wall was a systems administrator at the time. With the release of Perl 5, the language changed to support more general programming - Larry was working as a general programmer by then. This change of use has left the language with some oddities and a syntax that has been likened to line noise. However, if you look at the good parts (O'Reilly haven't announced "Perl: The Good Parts", but it's a book that's crying out to be written), there's a really nice language in there. Arguably there's at least two. There's the language of the one-liner, the quick throwaway program written to achieve some sysadmin related task, and there's the more 'refined' language you use when you're writing something that is going to end up being maintained.
I think it's this split personality that can put people off the language. They see the line noise of the one liner school of programming, the games of Code Golf (originally called Perl golf, the idea spread), the obfuscated Perl contests, the terrible code that got written by cowboys and people who didn't know any better in the dotcom bubble (you can achieve an surprising amount with terrible Perl code, but you will hit the wall when you try and change it) and they think that's all there is.
But there is another Perl. It's a language that runs The Internet Movie Database, Slashdot, Booking.com, Vox.com, LiveJournal and HiveMinder. It's a language which enables people to write and maintain massive code-bases over years, supporting developers with excellent testing and documentation. It's a language you should be considering for your next project. It's also something of a blue sky research project - at least, that's how some people see Perl 6.
Perl 6
Perl 6 has been a long, long time in coming. Its gestation period makes elephants' pregnancies seem like the blink of an eye. Jon Orwant (co-author of Programming Perl and O'Reilly CTO) threw the coffee mugs that precipitated the Perl 6 effort, during a meeting at the Perl Conference in 2000. In those 8 years, Perl 5 has seen two major releases. Meanwhile, Perl 6 continues to creep closer to its 'Christmas' release.
There are encouraging signs. The Perl Foundation recently received a $200,000 grant from Ian Hague to support Perl 6 development; key projects have well defined roadmaps and have been hitting their targets; and Patrick Michaud, who leads the development of Rakudo (Perl 6 on the Parrot virtual machine), has said that it is starting to 'feel like Perl' (and rakudo has been able to run a growing subset of Perl 6 for a long time).
I think we're unlikely to see a full Perl 6 before Christmas 2009, but there's a history of announcing interesting developments at the Open Source Conference.
If you consider yourself to be, in the words of one core Parrot hacker I spoke to, "a language dilettante and you like saying 'How much code didn't I have to write to solve that problem?'" then the next couple of months should be very interesting.
Probably Perl 6's biggest impact so far is the effect it's had on the Perl 5 ecosystem, as ideas trickle down into Perl 5 implementations and CPAN libraries. If you've used Perl 5 before, but it's been a while, then 2009 will be a good year to take another look.
Perl 5, Version 10
Perl 5 version 10.0 (traditionally, this has been called Perl version 5.10.0, but I, and some of the people I interviewed for this article, think there's a case for breaking with that - Perl 5 has seen substantial changes in its point releases) was released in December 2007 and version 10.1 is expected soon (10.0 was described as a 'testing' release). There's lots of new stuff in version 10. For instance, it introduced a native switch statement (called given
/when
, it's an example of fruitful theft from Perl 6 - though you might like to wait for 10.1 to get something that more nearly matches the current Perl 6 spec) alongside other Perl 6 borrowings like the //
(defined or) operator and say()
(a convenience version of 'print' that automatically appends a new line. Not every change is huge, sometimes it's all about convenience). The regular expression engine has also been significantly improved, gaining new features as well as, arguably, a larger population of developers who understand how it works under the hood. (It used to be said that there were 3 +/- 5 people in the world who understood how the perl regular expression engine worked.)
Perl 5 development has also moved over to git for source control (replacing the proprietary Perforce and an svn mirror). It's too early to say if this change will have a large effect on the development process, but a repository containing 21 years of changes makes for a substantial initial 'git clone' step.
Positive though these developments in the language itself are, the real meat of modern Perl is the Comprehensive Perl Archive Network (CPAN), a vast repository of good, bad and downright ugly code, for almost every eventuality. If you're setting out on a project in Perl, the first step is to search CPAN (at http://search.cpan.org) to see if there's a ready to use solution.
On most systems, the process of installing a module and its dependencies has been a matter of issuing the command 'cpan DBI DBD::Sqlite' say, then sitting back while the tool fetches the DBI and DBD::Sqlite module and their dependencies, compiles anything that needs compiling and installs everything in an appropriate place. If you're on a system that has a readily accessible compiler, it's all pretty much automatic.
The fly in the ointment here has been the Windows platform. Getting access to a Windows compiler isn't quite as easy as it is on other platforms and that's tended to mean that Windows Perl hasn't been seen as a 'proper' Perl. Sure you can make it work, but there's a lot of ground work before you can compile even the simplest XS module (XS modules are those which are partially implemented in C).
Which is where the 'Perl-on-a-Stick' project saves the day. In 2008, Adam Kennedy was funded by the Perl Foundation to make his Strawberry Perl Windows distribution relocatable and he succeeded spectacularly. This means that there's now a Windows distribution of Perl which you can copy to a 128M memory stick and which gives you a fully relocatable distribution of Perl and the full tool-chain needed to install pretty much any module from CPAN. On top of this, Adam has managed to get Microsoft involved in providing a testing facility for a CPAN author to test their modules on various windows platforms as well as whatever platform they happen to develop on. Given the ongoing drive for quality on CPAN this is huge.
"The New Perl Enlightenment"
CPAN is also where you'll find evidence of what one phrasemaker 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.
Of frameworks and the future
Catalyst, by the way, is another MVC oriented Web framework. If you've got a handle on Rails, you've probably got a handle on Catalyst. Catalyst seems to be the dominant web framework in the Perl community and, in keeping with the Perl spirit, it's less opinionated. Where Rails knows what's best for you and can make it a little tricky if you want to do things differently, Catalyst is of the the opinion that you know what's best for you, and lets you work your way.
If you like less conventional approaches to web application development, you might find Jifty more to your taste. Taking its cues from Seaside (an amazing Smalltalk based framework that turns web development on its head), Jifty aims to make it easy to write highly interactive web applications that would be tricky to manage in a RESTful style. Continuity, by Brock Wilcox and Scott Walters, is another Seaside inspired library that seems to be stuffed with ideas.
Every write up of a language nowadays will claim that the language has an active and friendly developer community. Perl's community is no exception, though parts of it can get cranky. Newcomers to Perl can learn a great deal about Perl and the Perl Way from communities like Perlmonks, which is both a forum for straightforward Q & A and for longer articles known as "meditations" which cover topics in more depth. Other sites worth a look are Use Perl, Perl Buzz, perl.com and The Perl Foundation.
According to Jonathan Corbet, writing on LWN.net, 2009 "will be a make-or-break year for Perl. If the Perl developers cannot either bring new life to Perl 5 or turn Perl 6 into something real, this language will, by the end of the year, have moved well down the road to "legacy" status."
I wonder if he's looking at the same language as me. I see an active Perl 5 community, working on and with, excellent tools on CPAN. Sure, version 10.1 could have arrived sooner, but that appears to be being rectified. I see Perl 6 and Parrot hitting their targets. This isn't crystal ball gazing. This is what's happening now. Phrases like "make-or-break" might make sense for a language that's moribund, but if you've read this far, you'll know that Perl isn't moribund. 2009 won't be a make or break year - I doubt we'll see fireworks, but I think that developments like Perl-On-A-Stick and Moose will continue to make life easier for curious newcomers, old hands and even returnees like me.-----------------------------
BY Piers Cawley
Source:heise
Piers Cawley is a veteran Perl programmer with 10 years service who has spent the last couple of years in a lucrative dalliance with Ruby, but who is returning to the Perl fold for personal work. Between 2002 and 2005, he wrote regular summaries of activities in Perl 6 development for perl.com.
0 comments:
Post a Comment