Sign In/My Account | View Cart  
advertisement


Listen Print

Perl 6 : Not Just For Damians
by Piers Cawley | Pages: 1, 2, 3, 4

"Perl 6 inspires fear."

Well, maybe. But it also just flat out inspires. If you don't believe me, take a look at the response to Perl 6 on CPAN. Damian's Attribute::Handlers successfully attempts to graft some of Perl 6's ease of manipulation of attributes back into Perl 5, and does a remarkably good job of it. Just look at all the really cool new modules that have sprung up around it. And that's just a small part of what we're going to get with Perl 6.

There are many new modules that exist only to 'mutate' perl5 behaviour -- NEXT, Hook::LexWrap, Aspect, Switch, Coro etc. I would argue that many of these have arisen in response to discussions about making Perl 6 a far more mutable language than Perl 5. And, if nothing else, these modules have gone some way to demonstrating that even now, Perl is more flexible than we ever realised.

Perl 6 is taking too long

I'm not quoting anyone else here; that's me complaining. I want it all and I want it now! But I also want a well thought out and coherent design. The choice between doing it Right and doing it Now is not a choice. Doing it Right is imperative.

The changes that Larry is making to the language will have far reaching and probably unforeseen consequences. But that's no reason for shying away from them. I've been programming in Perl for long enough to remember the transition from Perl 4 to Perl 5, and I remember delaying my own move to perl 5 for an embarrassingly long time. I didn't understand the new stuff in 5 and I hadn't a clue why anyone would want it, so I put off the move.

Eventually, I held my nose and jumped in. References were so cool. The new, 'real', data structures meant an end to contortions like:

    $hash{key} = join "\0", @list;
    # and later...
    @list = split /\0/, $hash{key};

Within a remarkably short space of time almost everything that had confused and scared me became almost second nature. Stuff that had been a complete pain in Perl 4 was a breeze Perl 5 (who remembers Oraperl now?) It seemed that all you had to remember was to change "pdcawley@bofh.org.uk" to "pdcawley\@bofh.org.uk".

Advanced Perl Programming Advanced Perl Programming
Sriram Srinivasan
August 1997
1-56592-220-4, Order Number: 2204
427 pages, $34.95

The same thing is going to happen with Perl 6. Even if it doesn't, all those perl 5 binaries aren't going to disappear from the face of the earth.

What I'm most looking forward to are the gains we're going to see from Perl becoming easier to parse. Over in the Smalltalk world they have this almost magical thing called the 'Refactoring Browser' which is a very smart tool for messing with your source code. Imagine being able highlight a section of your code, then telling the browser to 'extract method'.

The browser then goes away, works out what parameters the new method will need, creates a brand new method which does the same thing as the selected code and replaces the selected section with a method call.

This is Deep Magic. Right now it's an almost impossible trick to pull off in Perl, because the only thing that knows how to parse Perl is perl. It is my fond hope that, once we get Perl 6, it's going to be possible to implement a Perl refactoring browser, and my work with ugly old code bases will become far, far easier.

But even if that particular magic wand never appears, Perl 6 is still going to give us new and powerful ways to do things, some of which we'd never even have tried to do before. Internally it's going to be fast and clean, and we're going to get real Garbage Collection at last. If Parrot fulfils its early promise, we may well see Perl users taking advantages of extensions written in Ruby, or Python, or Smalltalk. World peace will ensue! The lion will lay down with the lamb, and the camel shall abide with the serpent! Cats and dogs living together! Ahem.

Related Articles

Apocalypse 3

Exegesis 3

It's been a long strange trip from perl 1.0 to where we are today. Decisions have been taken that made sense at the time, which today see us lost in a twisty little maze of backward compatibility (or should that be a little twisty maze...). Anyone who looks at the source code for Perl 5 will tell you it's scary, overly complex, and a complete nightmare to maintain. And that's if they understand it.

Perl 6 is our chance to learn from Perl 5, but Perl 6 is also going to be Perl remade. If everything goes to plan (and I see no reason why it won't) we will arrive at Perl 6 with the crud jettisoned and the good stuff improved. We'll be driven by a gleaming, modern engine unfettered by the limitations of the old one. We'll have a shiny new syntax that builds on the best traditions of the old to give us something that is both brand new and comfortingly familiar.

And there, in the Captain's chair, you'll still find Larry, smiling his quiet smile, comfortable in the knowledge that, even if he doesn't know exactly where we're going, it'll be a lot of fun finding out. Over there, at the science officer's station, Damian is doing strange things with source filters, haikus and Quantum. A calm voice comes up from engineering; it's Dan, telling us that the new engines can take it. And at the helm Nat Torkington gently steers Perl 6 on her continuing mission towards new code and new implementations.

And Ensign Cawley? Well... there's a strange alien device called a refactoring browser. I'm going to be replicating one for Perl.