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.
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.
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!
Everyone attacks Perl code for being unreadable but I don't think I've ever come across real world Perl code that I couldn't manage to deal with (eventually). I've seen some bad code and written some bad code and Perl doesn't have exclusivity in either of those areas. ;)
Does someone have a good example of unreadable, real world Perl code? And I don't mean obfuscated Perl contest entries.
When it comes down to it, other people's code is just freakin' unreadable no matter what they write it in. In fact, my own code looks unreadable and unmanagable if I haven't seen it in awhile. Just the nature of the industry.
Maybe Perl is just a high profile target since the internet is full of small (and useful) pieces of Perl code?
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
I believe that CPAN is one of the major (if not the only) things keeping Perl alive and well.
My own experience suggests this is absolutely true. I learned a bit of Perl in 2000, then had a look at Python, and realized that 90% of what I wanted to do, no matter what I wanted to do, was already implemented in Perl modules. Python, in contrast, had a a much, much smaller collection of stuff available. Despite certain nice features in Python, the abundance of pre-existing native functionality in Perl won the day for me.
One could argue that Perl functionality can always be called by other languages, but I have extensive experience in mixed-language programming (C/FORTRAN, C++/Java and Perl/C++) and don't really want to deal with the debugging nightmare that it often entails. So given that I could do everything I wanted to in Perl and still live by Booch's Rule 122 ("Never write code unless you absolutely positively must"), Perl was the clear choice.
The only likely replacement for Perl is Perl, as Perl6 will be able to draw on the huge community of Perl developers who have a vested interest in keeping the language alive and flourishing, and it is very likely that debugging from Perl6 into Perl5 will be relatively seamless.
Blasphemy is a human right. Blasphemophobia kills.