Posts in this category
- Strings, Arrays, Hashes;
- Basic Control Structures
- Subroutines and Signatures
- Objects and Classes
- Regexes (also called "rules")
- Comparing and Matching
- Containers and Values
- Where we are now - an update
- Changes to Perl 5 Operators
- Custom Operators
- The MAIN sub
- Regexes strike back
- A grammar for (pseudo) XML
- Subset Types
- The State of the implementations
- Quoting and Parsing
- The Reduction Meta Operator
- The Cross Meta Operator
- Exceptions and control exceptions
- Common Perl 6 data processing idioms
Mon, 08 Dec 2008
The State of the implementations
"Perl 5 to 6" Lesson 22 - The State of the implementations
Note: This lesson is long outdated, and preserved for historical interest only. The best way to stay informed about various Perl 6 compilers is to follow the blogs at http://planetsix.perl.org/.
Perl 6 is a language specification, and multiple compilers are being written that aim to implement Perl 6, and partially they already do.
Pugs is a Perl 6 compiler written in Haskell. It was started by Audrey Tang, and she also did most of the work. In terms of implemented features it might still be the most advanced implementation today (May 2009).
To build and test pugs, you have to install GHC 6.10.1 first, and then run
svn co http://svn.pugscode.org/pugs cd pugs perl Makefile.PL make make test
That will install some Haskell dependencies locally and then build pugs. For
make test you might need to install some Perl 5 modules, which you can do with
Pugs hasn't been developed during the last three years, except occasional clean-ups of the build system.
Since the specification is evolving and Pugs is not updated, it is slowly drifting into obsoleteness.
Pugs can parse most common constructs, implements object orientation, basic regexes, nearly(?) all control structures, basic user defined operators and macros, many builtins, contexts (except slice context), junctions, basic multi dispatch and the reduction meta operator - based on the syntax of three years past.
Rakudo is a parrot based compiler for Perl 6. The main architect is Patrick Michaud, many features were implemented by Jonathan Worthington.
It is hosted on github, you can find build instructions on http://rakudo.org/how-to-get-rakudo.
Rakudo development is very active, it's the most active Perl 6 compiler today. It passes a bit more than 17,000 tests from the official test suite (July 2009).
It implements most control structures, most syntaxes for number literals, interpolation of scalars and closures, chained operators,
END blocks, pointy blocks, named, optional and slurpy arguments, sophisticated multi dispatch, large parts of the object system, regexes and grammars, Junctions, generic types, parametric roles, typed arrays and hashes, importing and exporting of subroutines and basic meta operators.
If you want to experiment with Perl 6 today, Rakudo is the recommended choice.
Mitchell Charity started elf, a bootstrapping compiler written in Perl 6, with a grammar written in Ruby. Currently it has a Perl 5 backend, others are in planning.
It lives in the pugs repository, once you've checked it out you can go to
misc/elf/ and run
./elf_f $filename. You'll need ruby-1.9 and some perl modules, about which elf will complain bitterly when they are not present.
elf is developed in bursts of activity followed by weeks of low activity, or even none at all.
It parses more than 70% of the test suite, but implements mostly features that are easy to emulate with Perl 5, and passes about 700 tests from the test suite.
Flavio Glock started KindaPerl6 (short kp6), a mostly bootstrapped Perl 6 compiler. Since the bootstrapped version is much too slow to be fun to develop with, it is now waiting for a faster backend.
Kp6 implements object orientation, grammars and a few distinct features like lazy gather/take. It also implements
BEGIN blocks, which was one of the design goals.
v6 is a source filter for Perl 5. It was written by Flavio Glock, and supports basic Perl 6 plus grammars. It is fairly stable and fast, and is occasionally enhanced. It lives on the CPAN and in the pugs repository in
Smop stands for Simple Meta Object Programming and doesn't plan to implement all of Perl 6, it is designed as a backend (a little bit like parrot, but very different in both design and feature set). Unlike the other implementations it aims explicitly at implementing Perl 6's powerful meta object programming facilities, ie the ability to plug in different object systems.
It is implemented in C and various domain specific languages. It was designed and implemented by Daniel Ruoso, with help from Yuval Kogman (design) and Paweł Murias (implementation, DSLs). A grant from The Perl Foundation supports its development, and it currently approaches the stage where one could begin to emit code for it from another compiler.
It will then be used as a backend for either elf or kp6, and perhaps also for pugs.
Larry Wall wrote a grammar for Perl 6 in Perl 6. He also wrote a cheating script named
gimme5, which translates that grammar to Perl 5. It can parse about every written and valid piece of Perl 6 that we know of, including the whole test suite (apart from a few failures now and then when Larry accidentally broke something).
STD.pm lives in the pugs repository, and can be run and tested with perl-5.10.0 installed in
/usr/local/bin/perl and a few perl modules (like
cd src/perl6/ make make testt # warning: takes lot of time, 80 minutes or so ./tryfile $your_file
It correctly parses custom operators and warns about non-existent subs, undeclared variables and multiple declarations of the same variable as well as about some Perl 5isms.
Many people ask why we need so many different implementations, and if it wouldn't be better to focus on one instead.
There are basically three answers to that.
Firstly that's not how programming by volunteers work. People sometimes either want to start something with the tools they like, or they think that one aspect of Perl 6 is not sufficiently honoured by the design of the existing implementations. Then they start a new project.
The second possible answer is that the projects explore different areas of the vast Perl 6 language: SMOP explores meta object programming (from which Rakudo will also benefit), Rakudo and parrot care a lot about efficient language interoperability, grammars and platform independence, kp6 explored BEGIN blocks, and pugs was the first implementation to explore the syntax, and many parts of the language for the first time.
The third answer is that we don't want a single point of failure. If we had just one implementation, and had severe problems with one of them for unforeseeable reasons (technical, legal, personal, ...) we have possible fallbacks.
Elf: http://perl.net.au/wiki/Elf source: see pugs,
KindaPerl6: source: see pugs,
v6.pm: source: see pugs,
STD.pm: source: see pugs,