Oakland.pm

Reviews

Review of "Perl 6 and Parrot Essentials"

authors: Allison Randal, Dan Sugalski, Leopold Tötsch

reviewer: George Woolley


Perl 6 and Parrot Essentials, 2nd Edition
By Allison Randal, Dan Sugalski, Leopold Tötsch
2nd Edition June 2004
ISBN: 0-596-00737-X
294 pages, $29.95 US, $43.95 CA, £20.95 UK

Notes:

  • published by O'Reilly
  • Click on the cover image above to go to the O'Reilly catalog entry.

Short Review

Very good. :) :) :) :) of 5.

Perl 6 is not here yet. Even the definition of the language is still in flux. But many things are reasonably clear, and certainly much clearer than a little over a year ago when the first edition of this book came out.

From my perspective, the highlights of Perl 6 are

  • Perl 6 is the Perl community's rewrite of Perl.
  • In Perl 6 there are rules which are way clearer and more powerful than regular expressions.
  • In Perl 6 object orientation is pervasive but not intrusive.
  • Perl 6 depends on the Parrot engine for both compiling and running.
  • Other languages will also run on the Parrot engine, e.g. Perl 5, Ruby, Python.

And there's much more. I've only included what seems most important from my limited perspective.

This book

  • describes the structure and functioning of the projects to develop Perl 6 and Parrot
  • gives the design philosophy underlying the Perl 6 language and briefly describes the syntax and semantics of some key features of the language.
  • gives an overview of the Parrot engine and provides Parrot language information including reference material for assembler codes, etc.

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 the Parrot engine that underlies it; and you'll also learn what you need to know to follow the on-going development and to get involved (if you want to).

If you wish, see my somewhat longer review.

George Woolley of Oakland.pm and Camelot.pm

Notes:

  • I gave the same rating to this second edition that I did to the first edition. However, this edition is both clearer and more complete.
  • So why the same rating? It's a judgment call that's influenced by my perception of the degree of difficulty. This edition is clearer and more complete, but IMO the first edition was more challenging mainly because the development was less far along.

Miscellaneous

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

Chapter Titles

  • 1. Project Overview
  • 2. Project Development
  • 3. Design Philosophy
  • 4. Basic Syntax
  • 5. Subroutines
  • 6. Objects
  • 7. Grammars and Rules
  • 8. Parrot Internals
  • 9. Parrot Assembly Language
  • 10. Parrot Intermediate Representation
  • 11. Parrot Reference

Note:

Basic Flow on Parrot

  • source code
  • <Parser>
  • Abstract Syntax Tree (AST)
  • <Compiler>
  • bytecode
  • <Optimizer>
  • bytecode (optimized)
  • <Interpreter>

Notes:

  • This is a simplified picture. For example, for a particular language, the Parser and Compiler may be replaced by a single component designed for that language.
  • <...> indicates ... is a module.
  • The input for a module is indicated on the preceding line and the output on the following line.

Some On Topic Links

Some Humor Links

Note:

  • The Fun Stuff links mostly have to do with computers, but mostly they don't relate to Perl, much less Perl 6. It would be reasonable to say they are way off topic. But do you care?

Acronym Soup

As is often the case in technical books, you'll encounter a healthy dose of acronyms. Here's some of them

  • AST: Abstract Syntax Tree. [8]
    a digested form of a program that the Parrot compiler can understand. output of the Parser.
  • CISC: Complex Instruction Set Computer. [8]
    a processor designed with a large set of instructions, some of which are complex.
  • COW: Copy on Write. [9]
    new memory is assigned only when necessitated by an assignment.
  • CPAN: Comprehensive Perl Archive Network. [2]
    central repository (plus mirror sites) for Perl modules and such.
  • CPS: Continuation Passing Style. [8]
    a powerful alternative scheme for (subroutine) call/return.
  • CVS: Current Versioning System. [2]
    a widely used source-code control system. the source-code control system for the Parrot project.
  • DWIM: Do what I mean. [3]
    one of the design principles on which Perl is based.
  • IEEE: Institute of Electrical and Electronics Engineers. [8]
    a professional society and a standards body.
  • JIT: Just in Time. [8]
    the attribute of taking action only when necessary. Parrot includes both a traditional bytecode interpreter and a high performance JIT interpreter.
  • JVM: Java Virtual Machine. [8]
    the part of the Java runtime environment that interprets bytecode.
  • NCI: Native Call Interface. [9]
    for calls on shared library functions with a known prototype.
  • PASM: Parrot Assembly Language. [9]
    the assembly language for the virtual CPU of the Parrot virtual machine.
  • PIR: Parrot Intermediate Representation. [10]
    an assembly language for Parrot that hides some details (such as register allocation). not a higher level language, but unlike PASM has many higher level features. PASM code can be intermixed with PIR code.
  • PMC: Parrot Magic Cookie. [9]
    one of four Parrot types; the others are integer, floating point number and strings. PMCs can define complex types (e.g. arrays & hashes); PMCs can define low-level objects.
  • Ponie: Perl on new internal engine. [1]
    A project to put Perl 5 on Parrot.
  • POSIX: Portable Operating System Interface for UniX [7]
    a series of standards developed by IEEE that specify a portable operating system interface. One of the standards is for character classes.
  • RISC: Reduced Instruction Set Computer. [8]
    a processor designed with a small set of simple instructions.
  • RT: Request Tracker. [2]
    the ticketing system used by the Parrot project for tracking bugs.
  • TMTOWTDI: There's more than one way to do it. [3]
    one of the design principles on which Perl is based.
  • TPC: The Perl Conference [1]
    a yearly Perl conference.

Notes:

  • Above, [x] means there is a significant occurrence of this acronym in chapter x.
  • Not everything above is an acronym. Cut me some slack, OK?
  • Some of the acronyms that are in the book but aren't included above are: CPU, FIFO, GUI, I/O, OO, RAM. Hopefully, you are familiar with these and at least a few of the one's I list above.

Request for Feedback

Let me know at george in the domain of metaart.org if you feel that:

  • I am wrong in general or in particular.
  • Something is poorly stated.
  • etc.

Thanks for considering giving feedback.

Acknowledgement

Thanks to Zed Lopez, who critiqued a draft of this review.


Somewhat Longer Review

Contents

Notes:

  • Most of my reading of this book has been on Safari Tech Books Online.
  • To learn more about Safari, click on the image of the logo above.
  • Or see my review of Safari.
  • I wrote the review of Safari over a year ago, but my high opinion of it has not changed.
  • As of 2004-07-11, there were 2309 books on Safari.

The Cover and the Title

O'Reilly titles and covers generally do a good job of conveying what to expect in a book.

What's Perl 6?: The Perl 6 language is

  • the next version of Perl
  • being worked on right now
  • a major updating of the Perl language
  • intended to be cleaner and easier to use than Perl 5
  • the Perl community's rewrite of Perl
  • syntactically different from Perl 5

What's Parrot?: Parrot is a virtual machine, compiler, and interpreter all rolled into one. It's especially designed to be an engine for dynamic languages and most especially for Perl 6.

The current engine for implementing Perl (i.e. Perl 5) is language specific. Parrot replaces that engine. It's a complete rewrite. As well as supporting Perl 6, Parrot will support

  • Python
  • Ruby
  • Perl 5
  • and a bunch of other languages

What are O'Reilly Essentials books?: From what I understand, O'Reilly Essentials books

  • are early looks at fast evolving subjects
  • have Essentials as the last word of the title
  • are not definitive
  • will likely be replaced by something more definitive at a later time
  • in the meantime, will help you evaluate the technology

How does the title fit the book?: It fits well.

The book is certainly about Perl 6. And there are 5 chapters on the Perl 6 language. There's a whole chapter on Language Design Principles; and there are 4 chapters on the Perl 6 language itself.

There's also 4 chapters on Parrot. So the book is also about Parrot, as the title indicates.

And the book is indeed an Essentials book in the O'Reilly sense.

What else is on the cover?: Two other things on the cover are

  • "The Community's Rewrite of Perl"
  • "2nd Edition"

The first two chapters give a picture of how the community rewrite project is structured and how it functions. And you are invited to get involved.

As one would expect from a second edition of an Essentials book, this book is much more complete than the first edition.

About the Reviewer

I have some relevant background which helps me in reviewing this book, including

  • I've been using Perl since 1994.
  • I've made significant use of over 20 different computer languages. That includes coding in a number of different assembler languages.
  • I worked, for a while, at a company that specialized in compiler development. I've done some compiler development.
  • I enjoy playing with compiler techniques. E.g. I created a simple metacompiler that worked for fun.
  • I've worked on two operating system development projects.
  • I reviewed the first edition of this book.
  • I subscribed to the Perl 6 Language mailing list about a year ago (2003-07-13) and have been reading the posts since then.

Limitations: Some limitations I have in reviewing this book are

  • I'm a supporter of O'Reilly.
  • I'm an advocate of Perl.
  • I'm not a language or a compiler expert. Nor am I a Perl expert.
  • I have no inside knowledge concerning the Perl 6 development.
  • I don't always follow what's being said in the posts on the Perl 6 language mailing list.

The Why of it All

OK, 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 and Parrot are it.

Note:

  • If the idea that the Perl community could be in need of inspiration seems odd to you, I suggest reading the section "The Birth of Perl 6" in the first chapter of the book.

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

  • Parrot is designed to be relatively easy to modify and evolve.
  • Parrot can be used for both Perl 5 and Perl 6 code.
  • Parrot can and is being used to implement Ruby and Python and some other languages
  • Parrot could even be used to create your own language.
  • With Parrot, features that people like can move easily between languages.
  • Parrot is also supposed to make it really easy to glue together programs coded in languages that run on Parrot.

Parrot is kool.

What You Get

The Project: The first two chapters are about the structure and operation of the project to create Perl 6 and Parrot.

For example, one of the topics addressed in these chapters is the process of Language design in Perl 6. The idea is that design in a particular area will move from

RFCs (Requests for Comments) short requests that anyone could make, that were subject to peer review and ultimately grouped by Larry Wall into one of around 30 areas
to Apocalypse Larry Wall's response to the RFCs in an area, accepting part or all of some RFCs and melding them together often in surprising ways
to Synopsis a summary of the Apocalypse
to Exegesis a practical code example that applies and explains what is described in the Apocalypse

Well, that's a simplification of what's said, and even a greater simplification of reality.

These two chapters have changed very little. But they have changed a tad. For example, there's a short new section on Ponie, the project to port Perl 5 to Parrot. (I want a Ponie. :)

The Perl 6 Language: There's a whole chapter on the design philosophy behind the Perl 6 language. This chapter is mostly unchanged from the first edition. There is a short new section on Huffman Coding. In this context that means "more commonly used features in the language deserve the best short-cuts".

There are four chapters on the syntax and semantics of the language. There are three important areas that have been expanded into separate chapters: subroutines, objects and grammars & rules.

Parrot: There are four chapters on Parrot. The first one is an overview of Parrot internals. There are chapters on the Parrot assembler and on the Parrot intermediate language. Finally, there's a chapter which is a reference for

  • the Parrot assembly language (PASM)
  • the Parrot Intermediate Representation (PIR)
  • Parrot command line options

Note:

The changes from the first edition reflect the evolution of Perl 6 and Parrot over the last year: much growth rather than radical change.

What's Good?

What I especially liked about this book was

  • that it provided updated info on this exciting development
  • the choice of what to cover specifically
  • the design philosophy chapter
  • the chapters on the Perl 6 language
  • the links that help one to get more up to date info

Gripes

When: Perl 6 rocks; I wish it were available now. Since it isn't, I wish the book said something about when to expect it. If noone has a clue, even saying that would be appreciated.

Synopses: From reading the book, you might think that for each Apocalypse that a Synopsis and an Exegesis always followed shortly. But recently when I checked (2004-08-13), I saw 8 Apocalypses but only 3 Synopses and 6 Exegeses.

The very critical Apocalypse on Objects came out in April of this year (2004-04-13), but there is still (as of 2004-08-13) neither a Synopsis nor an Exegesis. However, in this book, there is a whole chapter on Objects which to some extent fills that void.

AST: I would have appreciated some detail on what the Abstract Syntax Tree (AST) looks like.

The Compiler: The author's think the Parrot Compiler is simple and the least interesting part of Parrot. Very little is said about it.

IMO it's an important component of Parrot. I would have appreciated some detail on it. If it's simple, it shouldn't be too hard to describe. Such detail might be helpful to me in assessing how useful the compiler would be for me in language development.

Who's the Book for?

Likely you, if you've read this far.

IMO, the following would be among those who would benefit from reading this book:

  • Perl programmers who are Perl advocates and supporters (chapters 1-8)
  • Perl programmers who just want to get a better handle on what Perl 6 will be like (chapters 4-7)
  • hackers (in the good sense) who want be involved in the development of Perl 6 (all 11 chapters)
  • programmers who are interested in exploring the innovative language independent interpreter approach that Parrot represents, for whatever reason (chapters 8-11)

The book has some suggestions on this subject. (See the Preface.)

A number of people I've talked to say they really don't expect to pay much attention to Perl 6 until Perl 6 is released for general use. Well, if you think that way this book is not for you, since that release hasn't happened yet. Oh, well.

The development of Perl 6 has come a long way since the first Perl 6 Essentials book. So most people who got the first edition will want to get the second edition.

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:

  • the underlying motivation of the Perl 6 project [chapters 1, 3 & 8]
  • the history and structure and workings of the project [chapters 1 & 2]
  • the Perl 6 language [chapters 4-7]
  • the new compilation and interpretation environment [chapters 8-11]

How does one get involved? From reading the book, I gather that the simplest way to get involved is:

  • join a mailing list
  • watch the traffic regularly
  • get a good sense of what is going on

After you've done these things, then when you have an insight, make a post to the list.

As a result of reading the first edition of this book, I joined the perl6-language list a little over a year ago.

Final Thoughts

This book provides key information concerning the evolving Perl 6 and Parrot. It answers (sometimes tentatively) such questions as:

  • How is the project to create Perl 6 structured?
  • What is the design philosophy underlying the Perl 6 language?
  • What are the syntax and semantics for creating and using subroutines? Objects? Grammars & rules?
  • How does Parrot work internally?
  • Where can I learn more about Perl 6 and Parrot?
  • And more.

This is a well-conceived book on an exciting subject.

Completed: 2004-08-25d

Added: acknowledgement 2004-08-27