Note
RecommendationA very good book. Perl 6 is not here yet. Even the definition of the language is still in flux. But many things are reasonably clear. If you are big into Perl or for some other reason wish to explore this developing technology, this is the book for you. It's an exciting, well conceived book. You'll be exposed to the major aspects of Perl 6; and you'll also learn what you need to know to go further, to follow the on-going development, and to get involved (if you wish). For a deeper examination, see my detailed review. George Woolley, Oakland.pm Quote from Larry Wall"The essence of Perl is really context sensitivity, not just to syntactic context, but also to semantic, pragmatic, and cultural context. This overall philosophy is not going to change in Perl 6, ..." -- from Apocalypse 1
[top] Chapter Titles
Note
Basic Flow
Notes
[top] Some Relevant Links
Some Google Searches
Notes
Notes
[top] Request for FeedbackLet me know at george in the domain of metaart.org if you feel that:
Thanks in advance for caring enough to comment. Acknowledgments, etc. are also appreciated. AcknowledgementThanks to Edwin S of Oakland.pm who reviewed a late draft of this review and asked many penetrating questions. [top] |
Contents
Notes
[top] The TitleI've found that O'Reilly titles do a good job of conveying what to expect in a book. So let's examine the terms in the title. What's Perl 6? I'll assume that you are familiar with Perl. Perl 6 is:
paradigm shift: There are a number of radical shifts in the movement from Perl 5 to Perl 6. Here's two:
Here's a quote regarding the first.
"The way I look at it,
Perl 5 was a composition largely by a single composer - me.
It's a fine classical composition,
but in essence it's one person's view of how to make music.
If you work with Perl 5 you have to follow the score pretty closely.
Perl 6 is going to be designed by the community.
We're going to be doing some jamming."
Essentials? From what I understand, O'Reilly Essentials books:
How does the title fit the book? It fits well. The book is indeed about Perl 6. It's also, necessarily, about Parrot, since Parrot, though language neutral, is the interpreter for Perl. And the book is indeed an Essentials book in the O'Reilly sense. It does give us an early look at Perl 6, but it's certainly not definitive. The authors are careful to say what they think is stable and what they think is likely to change. There's enough laid out that you can likely do a tentative evaluation of Perl 6 relative to your specific concerns. [top] About the ReviewerBackground: I have some relevant background which helps me in reviewing this book, including:
[top] The Why of it AllOK, here we go. Why Perl 6? Well some parts of the language are showing their age and getting unwieldy -- like regular expressions. Hey, people are making fun of all our special characters, and sometimes they have a point. And the internals are getting hard to maintain and extend. If we want the flexibility to grow with ease in the future (and we certainly do), we need a revised syntax and a new internal engine. And the people in the Perl community need something to be inspired by. Perl 6 is it. What's so good about Parrot? OK, but we could have just redesigned the language and rewritten the internals. Right? Possibly. But there are big advantages with Parrot such as:
Parrot is kool. Design Philosophy: There's a whole chapter on "Design Philosophy" [chapter 3]. A number of principles governing the Perl 6 design are explained there including:
The fundamental design philosophy hasn't changed. Perl is just growing up, refining its act in some areas and flexing it's muscles in others. One of the architectural considerations put forward is that "Perl Should Stay Perl" which includes:
Perl has always tried to take into account relevant natural language principles so there's continuity there too. The changes being made for Perl 6 are aimed at the flexibility, stability, and long term usability of the language. [top] The LanguageThere's a whole chapter on the syntax of Perl 6 [chapter 4] which has sections on:
I'd read a little about Perl 6 before I read this book, but much of the material in this chapter was new to me. I found it relatively easy to absorb and fascinating. I'll talk a little about just two of the many language changes. Switches: In Perl 5, there's no switch statement for handling cases, so I often write things in the following pattern (where what the ... and ..... are is left to your imagination):
if ( ... ) { ..... }
elsif ( ... ) { ..... }
elsif ( ... ) { ..... }
.....
else { ..... }
I'm aware of various other solutions, but this is, in fact, what I usually do. In Perl 6, there is to be a switch statement and a natural way to indicate cases. I'll likely start using that and write things in something like the following pattern:
given $topic {
when ... { ..... }
when ... { ..... }
.....
default { ..... }
}
given in this pattern is a topicalizer, that is, if elsewhere in this pattern you make an explicit or implicit reference to $_, you'll be referring to $topic (or whatever came after given). You may be wondering why the keywords used aren't switch and case rather than given and when. By the time you get to the point in the book talking about switches you'll know where to look for such answers. Here's something abstracted from some Perl 5 code I wrote:
if ( $kind eq "RULE" ) { ..... }
elsif ( $kind eq "ALT" ) { ..... }
elsif ( $kind eq "TEXT" ) { ..... }
.....
else { ..... }
In Perl 6, I'd likely write something like:
given $kind {
when "RULE" { ..... }
when "ALT" { ..... }
when "TEXT" { ..... }
.....
default { ..... }
}
To my mind, that's a much clearer expression. Anyway, that's a somewhat simplified view of what I learned from the book about switches in Perl 6. Rules: Historically, Perl has had the richest implementation of regexes of any language. And regexes are better integrated into Perl than into any other language. However, the notation used violates basic language principles in numerous ways and is not well suited for writing whole grammars. In Perl 6, we have rules (rather than regular expressions). And the notation for these rules:
Rules in Perl 6 do not have the same syntax as regexes in Perl 5. Well, if you really want them to, there is a rule modifier that allows you to specify that a pattern uses Perl 5 regex syntax. My guess is you won't want to do this. Perl 6 rules are both more readable and more powerful than Perl 5 regexes. What do the language changes mean to you? Well, how do I know? It depends on what you do, how you like to do it, etc. But I'll bet you find some things to be enthused by in this chapter. To me, the language changes are like a dream about to come true. :) [top] Major Components of the SystemModules: Perl 6 uses Parrot for it's internals. Running a Perl 6 program involves four major modules:
The Perl 6 Parser produces an Abstract Syntax Tree (AST) from Perl 6 source code. The Parrot Compiler produces bytecode from AST. (It also does some simple optimization.) The Parrot Optimizer produces optimized bytecode from bytecode. (It is an optional step in the process.) The Parrot Interpreter runs the bytecode. (In some cases, it may need to call the Perl 6 Parser to do its job.) Parrot: Parrot consists of:
The Parrot Parser is a general-purpose parser which can be used for different languages. Another option is to replace the parser with a parser tailored to the language which produces an AST. The replacement parser, for example, might be an already existing parser for the language. [Chapter 5 of the book describes the functionality of Parrot with an emphasis on the Interpreter.] Two Programs: The Parrot Assembler, assemble.pl, assembles bytecode from Parrot assembler code. [Chapter 6 describes the Parrot Assembler and the assembler language it is designed to process.] The Intermediate Code Compiler (IMCC), imcc, is a highly flexible program which, among other things:
[Chapter 7 describes IMCC and the intermediate compiler code that it can handle.] What happens to my Perl 5 code? This is an especially relevant question since Perl 6 is syntactically different from Perl 5. There are two things that address this that I know of:
And, of course, you could continue to run your Perl 5 progams exactly as you do now. :( [top] What's next?How does one learn more? Well, on the web mostly. And the material you'll be reading in the book will help you prepare for that by giving you the basics of:
And according to the Preface of the book, there will be a revised edition of the book each year until Perl 6.0.0 is released. How does one get involved? From reading the book, I gather that the simplest way to get involved is:
After you've done these things, then when you have an insight, make a post to the list. As a result of reading the book, I joined the perl6-internals list. I just joined it, and I'm still in the watch the traffic stage. [top] What I'd like differentWell, I think this is a very good first Essentials book. Still, it seems I always find something I'd like different. I had difficulty understanding just what components were being referred to in the overview of the Parrot architecture [in Chapter 5] and their relation to the Parrot Assembler and to IMCC [which are described in Chapters 6 & 7]. I wish this was all made inescapably clear. That's my list of things I wish were different in the book. Just one item on it. Oh, I do also wish that Perl 6 was already released. That's not about the book. But this is a very ambitious effort, and I keep wondering: "When will Perl 6.0.0 be released?" [top] Who's the Book for?Likely you, if you've read this far. I would think the people who would most likely benefit from this book are:
The book has some suggestions on this too. [preface] [top] Note
|
version 1.0.0 completed: 2003-07-23
Last Updated: 2003-07-24