Whenever in Perl 6

Herbert Breunung

"Rakudo *" (pronounced star) is the first version of a Perl 6 interpreter that is intended for a larger audience. Undoubtedly a big moment for developers, but what exactly can Perl users expect from it and what impact does the announcement have on Perl 5?

The name doesn't answer that question because it doesn't contain Perl 6 or well-known names like Alpha, Beta or RC (Release Candidate). That was a wise decision by project manager Patrick Michaud, because the moment you ask what the name means, you can deliver a message and repair some of the public relations work that was not going well for Perl 6.

History lesson

Contrary to popular perception, the OSCON 2000 (at that time still "The Perl Conference") was only the birthplace of the idea, which was initially followed by a two-year, public process of searching for opinions about what exactly could be improved on Perl. During this time, Dan Sugalski began designing and implementing the new Parrot virtual machine. Just as working out the syntax below is similar to finding the perfect language that contains everything that today's developers use successfully (plus a lot more), Parrot is aiming for an ambitious goal. It would like to become a virtual machine (VM) for as many dynamic languages ​​as possible, all of which should be usable in one program, so that the programs would have access to the libraries of all implemented languages. This requires universal parser tools that can divide the source code into logical units, syntax tree converters that recognize the logical structures and translate them step by step into a language that the VM understands (which is ultimately bytecode), bytecode interpreters and subsystems that convert the bytecode Execute commands, optimizers and much more.

The infrastructure is at least mature enough that two and a half years ago, in front of an amazed audience, developers wrote a Parrot compiler for the fun language LOLCODE in one afternoon. During that time work began on the current form of the Perl 6 compiler for Parrot, which is called Rakudo. It will cross the finish line as the long-awaited Perl 6.0, but it will not call itself that. Because everything can be called Perl 6, which passes the test suite currently counting around 40,000 individual tests, which covers large parts of the specification (synopses), which is still slightly changing. This is more than rhetoric, because at least five other implementations (Pugs, elf, Mildew / SMOP, Perlito, viv) pursue different goals with different technology. One of the implementations contains the Perl 6 specification of the syntax that the head of the language team, Larry Wall, maintains.

Since tests and small sample scripts are not the "real programmer's life", Johan Viklund and Carl Mäsak started the first major Perl 6 application, the site, with the wiki software November
november-wiki.org operates. November became the motor for a maturity phase, after which rakudo is probably good enough for a wider public. A new generation of Parrot's NQP tool contributes to this, allowing Rakudo to follow the Perl 6 syntax much more precisely. This and the fact that essential parts of the syntax will no longer change, allow the prediction that the "happening" will shift more and more into details and optimizations.

Now it takes the experience of many users so that the language and interpreter can become suitable for the masses and ready for production. But the many modules that make Perl really useful for some have yet to be written. With "Blizkost" (included in Rakudo *) there is a new approach to allow the Perl 5 modules within Parrot to be executed by a Perl 5.10 interpreter, and Rakudo users will also be able to use the Ruby and Python languages ​​as well as their Modules can use, but building a CPAN6 or 6PAN is also an important goal. Even more module authors could now start programming, which is why they should be presented with something that is publicly effective.

Star full of meanings

That is exactly what Patrick Michaud decided in the presence of the author at the YAPC :: EU 2009 in Lisbon. He said, "Whatever the status for the second quarter of next year will be published." This "whatever" (English Whatever) can be expressed in Perl 6 with an asterisk, since it stands for a placeholder type called "Whatever". Patrick intentionally broke out of known version schemes, since Rakudo * is not a beta, no RC, no 0.5 or 0.9, but a preliminary version with a claim to reliability, less to completeness.

However, it does not make sense to disdain Perl 5 in order to wait for a professionally usable Perl 6, because that does not come so quickly. Perl 5 is constantly evolving. Especially with Perl 5.10 (Perl 5.12 is currently), but also with Moose, a modern and powerful object system, a number of Perl 6 ideas were added. Many other concepts from Perl 6 can already be tried out within Perl 5 with the Perl6 :: * modules of the same name, but always within the old syntax limits. What Rakudo offers is a "barrier-free" foretaste of a designated part of Perl 6, with which larger programs can be written, but which are likely to be unacceptable for many in terms of speed and memory consumption.

Bridge between Perl 5 and Perl 6

The bridge between Perl 5 and Perl 6

But why bother with Perl 6? Because Perl 6 is an interesting language. She has learned from the mistakes of the past. A lot of things that Perl 5 beginners find difficult, such as context-sensitive sigils, idiosyncratic parameter passing and the free, but awkward to write object orientation, have either disappeared or become a non-standard option. The regex syntax has been thoroughly cleaned up and now obeys clearer rules. "use strict" became standard, and the special variables and exception handling show that Perl has grown up. The instruction set is now less reminiscent of a Unix shell, but more of simple, but IT-heavy English. The creators have retained the essential Perl philosophy.

According to the slogan "There is more than one way", Perl 6 tries to combine apparent opposites such as object orientation based on classes or prototypes, object-oriented and functional programming, strict and dynamic typing or even positional and named parameters. With this, Perl leaves the familiar limits of a "scripting language", but remains true to its old principle of combining the best of different worlds. Perl 1 was already an effective fusion of C and shell programming. Incidentally, Perl also achieves full "buzzword compatibility", where even questions about clinically clean macros or "design by contract" can only be answered with yes, yes and again yes.

According to Loriot, one can say: If you didn't like the fact that there is a wealth of solutions for everything in Perl 5, you will definitely not like Perl 6. Likewise, the large number of operators that can be combined with meta-operators should not be to everyone's taste, although it allows a dense and relatively readable writing style. On the other hand, there are nifty little detailed solutions, such as the "slurp" command (based on the Slurp module, which can assign the file content directly and does not require a file handle.

The really big reasons to check out Perl 6, even if you know all of the above from other languages, are as follows. What made Perl famous as a CGI language were, in addition to the good database drivers, the regular expressions that were previously only seen in awk and then found their way into almost all languages ​​as PCRE. However, since reading and processing HTML or e-mails leads to complex and barely understandable regular expressions, Perl 6 can divide a regex into many rules and group them into grammars. This allows handling like in lex and yacc, and the grammars can also be derived and expanded like other objects. Parrot's previously described parser tools work with it, and that's why a language definition written in Perl 6 can be compiled into a Parrot compiler.

The second big reason also has to do with grammars. In reality, Perl 6 is not a programming language, but a metalanguage with a beginner-friendly starting form, which can, however, be changed as required at runtime. Similar to Lisp, only with fewer brackets and a lot more basic vocabulary. It has complete introspection and at runtime both new operators can be defined and the internal objects of the interpreter can be changed. Even the parser that reads the sources is a grammar that can be adapted at any time. With just a few lines, the language can be aligned to the needs of the project, or your own small languages, so-called DSLs (Domain Specific Languages), can be easily created.

Perl 6's regular expressions are one such DSL. Technology can help bring together incompatible parts of extensive software systems with little effort. In a data world that is rapidly becoming more complex with many software legacies, this is certainly an important task. Another big trend in recent years is that of parallelism. It is possible to write applications for multiple processors or cores, but hardly any popular language has made it easy. Perl 6 knows several commands and operators that do not depend on the order in which the data is processed and that the interpreter can distribute on its own. Thus, even programmers who have not fully understood the underlying concepts are able to use parallelism, just as Perl 5 made functional programming principles such as closures and higher-order functions easy to use.

Those who want to delve deeper into the language can read the book supplied with Rakudo *, and those who prefer German will find several good tutorials on the net. Also included are the Parrot, which otherwise has to be installed separately, bridges to Perl 5 (Blizkost) and other languages ​​(Zavolaj) as well as some modules for a basic supply in terms of database, vector graphics, HTTP and a lot more.


Rakudo * is a relatively robust, but comparatively slow demonstration object of an ambitious long-term project. If you are interested in computer languages ​​or want to experience for yourself where Perl is headed, you can really enjoy it. However, he shouldn't set himself too high goals for his programs, because Perl 6 is expressive, but so far only a few modules can handle common tasks. (ane)

Herbert Breunung
regularly writes articles about application development in Perl and Perl 6 and speaks at national and international conferences. He has been running a free software project for years and is involved in setting up the Perl 6 documentation.

Online sources