Rakudo *'s Really Really Release Ready
How do you know when a new programming language is ready to be released? You try porting a real software framework to it. I recently completed a port of a Perl 5 framework to the Rakudo implementation of Perl 6, and guess what? It just works! This is my story...
After only a short ten year wait, a Perl 6 implementation is scheduled for release this month. Rakudo * (aka Rakudo Star) will be inaugurated on July 29th, 2010. Is it ready? That certainly depends on your expectations, but I am here to make the case that it is a usable programming language with at least one killer feature that will interest programming language addicts (like me).
I am an Acmeist Hacker, which is to say that I only like to work on projects that serve many programming languages. I have lots of these projects: YAML, TestML and JSYNC are three that I have been actively hacking on recently.
YAML, as you likely know, is a serialization language for all programming languages. TestML is a unit test language for all languages. It is useful for porting software (like YAML) and making sure it passes the exact same tests, everywhere. JSYNC is new. It's an attempt to combine the simplicity and robustness of JSON with the completeness of YAML.
A month ago, I gave a talk about Acmeism at YAPC::NA. Afterwards, one of the attendees, Nick Patch, and I decided to work on a JSYNC port to Perl 6. Since all the tests for the Perl 5 version of JSYNC are written in TestML, we decided that we would first need to port the TestML framework from Perl 5 to Perl 6. A month later, I can happily say that TestML has been completely (it passes all tests!) ported to Perl 6/Rakudo. The JSYNC port has not yet been started, but I did manage to write a fledgling Perl 6 YAML module along the way (with all of its tests written in TestML!!).
What was it like to work in Perl 6? Read on!
TestML is a small to medium sized framework. It consists of a half dozen object oriented modules. Prior I had written it in Perl 5 and in Python. The Perl 5 version is over a 1000 lines of code, not including the tests. Since TestML is a language, it needs to be compiled and executed. This accounts for TestML::Parser (which is driven by TestML::Parser::Grammar), and TestML::Runner. The runner class needs a subclass to connect it to an actual existing test framework; in Perl's case TestML::Runner::TAP. TestML::Document is a collection of classes that define the compilation unit. Then there is TestML::Bridge to connect TestML to the application you are testing, and a standard library called TestML::Standard. All of this code is very very dynamic, ie introspection based.
TestML itself, started with a TestML Specification which consists mostly of a grammar written in a pseudo grammar language. The grammar language is a top down set of productions and rules all of which eventually terminate into simple regular expressions (regexps). I turned this grammar into a YAML data structure and used the same YAML for the Python and Perl implementations. The implementations also use a common test suite, which is, of course, written in TestML. The Perl 6/Rakudo port was done, when the implementation passed all these tests!
When Nick Patch and I started hacking at YAPC, he suggested that we use Perl 6 Regexes, the new parsing technology that Perl 6 uses, instead of my YAML grammar stuff. I agreed, because I really wanted to learn this. This decision turned out to be life changing! We actually plopped the old YAML productions into a new Perl 6 module called TestML::Parser::Grammar, and spent just over an hour tweaking a few sigils to make it properly compiling Perl 6. But not only did it compile, it JUST FRICKIN WORKED! We had a passing parse test. The hard part was over.
Or so I thought. It took me a few weeks (and many a shaved yak) to get the last test passing. Rakudo is, um..., an adventure. I discovered and reported about a dozen bugs. I spent countless hours looking into crazy problems. It was a pretty even split between me learning a new language, a stupid programming mistake on my part, Rakudo not doing that part of Perl 6, and Rakudo just sucking it. The one part of Rakudo that never let me down was its amazing community. People hanging out on #perl6 and holding my hand as I danced (and danced and danced) barefoot across the bed of flaming coals that is Rakudo.
Part of the reason it took me so long, is that Rakudo is sloooooooooooow. No getting around that one for the time being. If your expectation of Rakudo * includes blazing speed... fuhgedabowdit! But if you don't mind taking a coffee break while your code runs far enough to produce a nice stack trace, give Rakudo a whirl. Luckily, I cut my hacking teeth writing mainframe code, where I did just that for years. That's why, I'm sure, I am forever addicted to coffee.
Rakudo has pretty good error reporting. Once in a while. Sometimes you get a full stack trace with a nice human touch error message (obviously written by Larry Wall) patting you on the back and saying "well, I know you tried really hard, and it would have been fine in Perl 5, but now you need to put a space after that twigil about halfway across line 369...". Many times you just get "Unable to parse blockoid, couldn't find final '}' at line 141". Oh really? What the heck is a blockoid, and, um, WHICH FRICKIN FILE??
I could go on and on about the fear and loathing but hey, trying to live in the future is never easy and I, for one, welcome our new Parrot-based Overlords. So how about Perl 6 as a language? As an Acmeist, my goal is to learn new languages and to spread goodness to all of them equally. My take so far on Perl 6 is that it's better than Perl 5. It feels really nice to code in. I also learned Python this year, and contributed a few modules to their CPAN. In many ways, I find Python to be even nicer than Perl 6, except for one important part...
Perl 6 Regexes
Perl 6 Regexes is Perl 6's killer feature. As somebody who has been searching for good parsing technology for over a decade, I really appreciate the thought put into this. It makes writing parsers a fairly simple task. As an Acmeist, I think it is vital that all languages have this technology. Since it was so easy for me to turn my home-baked TestML parser grammar into Perl 6 Regexes (P6R), I am already convinced that I can take a useful subset of P6R and make it work everywhere!
... *sigh* yet another project ...
Is Perl 6 Ready? It is ready enough for Rakudo!
Is Rakudo Ready? It is ready enough for TestML!
Is TestML Ready? It is ready enough for an Acmeist port of Perl 6 Regexes!