Slashdot Mirror


Perl 6 Now by Scott Walters

Joseph Brenner writes "Every now and then, a beginning programmer asks if there's any point in learning to program in Perl 5, when Perl 6 is going to change everything soon. There are a number of answers to that: one is to point out that Perl 6 is still years away, another is to point out that it is promised that Perl 5 code will run under Perl 6 without modification (a module that begins with the traditional "package" statement is Perl 5 code; if it begins with the new "class," then it's Perl 6)." Read on for the rest of Brenner's review of Scott Walters' Programming in Perl 6 style using Perl 5, a book which answers that question a whole different way. Perl 6 Now author Scott Walters pages 379 publisher Apress rating 7 reviewer Joseph Brenner ISBN 1590593952 summary Programming in Perl 6 style using Perl 5

Scott Walters here pursues what might be thought of as the third answer: you can learn Perl 6 now and immediately begin writing programs in a "Perl6ish" sort of way, using appropriate CPAN modules that have been used to implement approximations of Perl 6 behavior: Perl6::Variables, Perl6::Export, Perl6::Contexts, autobox, Perl6::Classes, Switch, and so on.

There are many caveats about using these tricks in production code, however, and Scott Walters doesn't shy away from warning you about them (e.g. p.43 "Source filters are dangerous" where he discusses their increased start-up overhead and potential bugginess -- though he doesn't mention my own peeve which is that they're very confusing when you try and use the Perl debugger).

So possibly the book is not really quite so well suited to an actual beginner-- who probably should not be told about "use Switch 'Perl6'", but the device of spending the early stages of the book directed toward a beginning audience makes it a very useful review for people like myself who have been reading the Apocalypses, but don't remember every detail.

And on the other hand, the book includes some prominent early warnings about common gotchas that beginning programmers seem to be prone to -- e.g. using dynamically defined variables instead of just using hashes.

The standards for writing English in the Perl world are pretty high -- the core members of the Perl community have always cared a lot about clear writing, and it's arguably the world's best documented language (critics will no doubt add that it needs to be). Unfortunately, I can't say that Perl 6 Now quite lives up to this standard. This is a book that was written in a hurry, and it shows: hasty sentences and minor organizational problems abound (e.g. one or two items seem to be discussed in the wrong place; there are an awful lot of explicit forward references, and yet there's at least one place where something was used in an example before being discussed a few dozen pages later). But then in Scott Walters defense, this is certainly a book that needed to be written in a hurry, because its subject matter is such a moving target.

And where the book really shines is in its code examples: short, clear and to the point; the author repeatedly shows how something can be done in Perl 5 code and how it's expected to work in Perl 6. These examples are always clearly labeled "Perl 5" or "Perl 6" in the comments, so that the two can't be confused.

The subjects of some of the examples are pretty cool: e.g. he talks about using PDL ("Perl Data Language") to crunch audio data in MOD format, which I was completely unfamiliar with. A *.mod file essentially contains the "sheet music" for multiple parts (really, MIDI) plus sound samples that specify how notes will sound for each voice. This is discussed in Chapter 7, which is also the free sample chapter. I also liked random walking Arizona's highways as an example of Graph navigation (Chapter 8, p 159), and I appreciate the fact that he downplays inheritance in favor of delegation in his discussion of objects (Chapter 14, p. 262).

All in all, this book is a fun read for the Perl fanatic.

(Note: the title Perl 6 Now bears a strong resemblance to an emacs package I've been working on called perlnow.el, but there is no relation.)

You can purchase Programming in Perl 6 style using Perl 5 from bn.com; it's also available in eBook format (password protected PDF, using your email as password) for $15. Source code and and a sample chapter are available online: Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

15 of 366 comments (clear)

  1. PHP5! by Douglas+Simmons · · Score: 5, Funny

    I hate to be Jonny Raincloud, but pretty soon PHP will be able to do whatever perl does, if it's not there already. And anything that it can't do that perl can will be obsolete. So no, don't waste your time learning perl 6. Do the right thing and brush up on your PHP5. I got my site to print in any font I want the time AND date, powered by php, baby!

    1. Re:PHP5! by Nuclear+Elephant · · Score: 4, Funny

      Does PHP have the equivalent of CPAN?

      Who would want a language that had its own mediocre congressional television station?

    2. Re:PHP5! by Momoru · · Score: 2, Funny

      BTW, It is customary to use the abbreviation NSFW when you post a link like this.

      I believe as the ass ambassador, he is entitled to diplomatic immunity in this case.

      At least I hope so since he is publishing so many copyrighted images illegally....

  2. Clear writing by Sweetshark · · Score: 4, Funny

    The standards for writing English in the Perl world are pretty high -- the core members of the Perl community have always cared a lot about clear writing
    Yeah, right. Why should one obfuscate English, Perl offers much more possibilities to do so.

  3. The author's last work was the most excellent... by Anonymous Coward · · Score: 1, Funny

    Duke Nukem: Forever Modder's Guide.

  4. Re:I hate Perl. by mopslik · · Score: 2, Funny

    What is the output of the following?

    "Be Sure To Drink Your Ovaltine." What the...?

  5. Re:Perl 9 is already out... by hahafaha · · Score: 2, Funny

    Would you care to provide any reasons for switching to Python?

    Holy wars such as Perl vs Python are typical but altogether unneccecary. Both Perl and Python are maturing and are now sophisticated languages. Furthermore, they are suited for different things. For example, if I were writing a program that needed advanced string parsing, I would use Perl. If I was writing a graphical game, I would use Python. If I was writing a CGI script, I would use Perl. If I was writing a program that described various objects in space, I would use Python.

    There is no reason to get so defensive about these things with the exceptions of Windows vs Linux (Linux) and Emacs vs Vi (Emacs).

  6. WORD by Anonymous Coward · · Score: 1, Funny
    PERL is completely obsolete. I've been programming PERL since 1984, and I can tell you that it's day is done. For example, this PERL program prints a message:
    $_="krJhruaesrltre c a cnp,ohet";$_.=$1,print$2while s/(..)(.)//;
    while this Python program does the same thing:
    import sys
    import re
    import string
    import trousers
    import letters
    import numbers
    import re again
    import sausage making guide
    import cars
    import import
    import print
    import def
    import class
     
    class Print_that_guy:
      def __repr__(self):
        return "Just another Python haxor!"
     
    that_guy = Print_that_guy()
    print (that_guy)
    PERL IS SO LAME!
  7. You mean slashdot isn't based in Poland? by rebug · · Score: 2, Funny

    Yow!

    --

    there's more than one way to do me.
  8. Wand Ad by Anonymous Coward · · Score: 1, Funny

    WANTED: RUBY DEVELOPER

    Willing to take anyone who knows the the difference between the scripting language and the gem. Must be willing to relocate to Bumfark, IA. Must agree that anyone not using Gentoo is a luddite. Send resumes in LaTeX to...

  9. I used to use Perl, now I'm only doing RoR by duffbeer703 · · Score: 5, Funny

    Ruby on Rails blows away Perl. I used to code in Perl, but I was working on re-implementing Windows XP as a Firefox extension, and I just wasn't getting the productivity that I wanted out of Perl.

    So I switched to Ruby on Rails this morning, and I'm so productive, that its sick. Within 5 hours, I have a Firefox extension running on my AIX workstation that can run most Win32 software... Photoshop, Outlook and Half Life 2 work ok, although I only get 40fps with HL2. (I'm working on that)

    After dinner I'm going to reproduce every module in the CPAN library, which I estimate will take approximately 2.25 hours. I can't wait!

    --
    Conformity is the jailer of freedom and enemy of growth. -JFK
  10. Re:Perl: Lead Painted Asbestos Toys for Tots by Anonymous Coward · · Score: 3, Funny
    It's simply irresponsible and foolish to use Perl.

    Every time you post a message to this website, you're using Perl. You'd better stop before you foolish irresponsible behavior catches up with you.

  11. Obligatory by value_added · · Score: 2, Funny

    I still find this funny.

    And still use Perl.

  12. Re:Why is Perl so hated? by Anonymous Coward · · Score: 1, Funny

    $rant = "And we refuse to let go of our power tools. You may use whatever language you like, but expect a well-deserved ass kicking if you get in our face and try to tell us you know better.";

    $rant =~ s/ass kicking/girly slapping/;

    Programmers are intimidating.

  13. Flame On! by Qbertino · · Score: 2, Funny

    First of all some TLC for you Perl Fanboys (and girls) out there: Everybody loves Perl. Perl is cool, fast, delivers fast results in the area it rules and is the grand daddy of OSS languages. Nearly all books on Perl are fun to read and at least a great laugh.
    In fact it's quite amazing how long this quirky relic of ancient Unix paradigms managed to survive. It's 2005 and Perl _still_ is taken for granted as a PL. That's a terrific feat!
    The only PL in the same demografic group that is still in use is SQL. And everybody agrees that SQL is a pain in the ass and the people who invented it -if still alive - should be wrapped in brabed wire and shot into the sun. Larry Wall on the other hand still is a hero. Perl is fun. Sort of like riding granddads old bike that has no gearshifts and weighs a metric ton. If you tighten all the screws, fill up the tires and give the chain a good greasing you can feel the raw power.

    Yet I choose Python over Perl because of it's better OOP capabilities and the fact that it's code only gets unreadable if you use brute force in making it unreadable. Python enforces good coding habbits making it handy for group projects and n00bs, has a strong foothold in lots of areas where Perl lacks (Gaming, GUI, 3D, large Web frameworks, etc ...) and is the best candidate for a Perl successor. It only lacks Perls unmatched regex features. Entry the famous saying:

    Perl is executable line noise, Python is executable pseudocode.

    However, all academic discussion aside: If you think it's important to be a 'manly' programmer by preferring outdated development habbits over modern and, yes, easyer PLs, you're being silly. Perl being cool or not, there are situations were it is plain irresponsible to use it.

    --
    We suffer more in our imagination than in reality. - Seneca