Created
July 20, 2010 20:46
-
-
Save ingydotnet/483559 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== 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) 1.0 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 <a href="http://acmeism.org">Acmeist Hacker</a>, which is to say | |
that I only like to work on projects that serve many programming | |
languages. I have lots of these projects: <a | |
href="http://yaml.org">YAML</a>, <a href="http://testml.org">TestML</a> | |
and <a href="http://jsync.org">JSYNC</a> 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 <a | |
href="http://yapc2010.com/yn2010/">YAPC::NA</a>. 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 <a href="http://github.com/ingydotnet/testml- | |
pm6">TestML</a> 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 <a href="http://github.com/ingydotnet/yaml- | |
pm6">Perl 6 YAML module</a> 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 <a href="http://github.com/ingydotnet/testml- | |
pm">Perl 5</a> and in <a href="http://github.com/ingydotnet/testml- | |
py">Python</a>. The Perl 5 version is over a 1000 lines of code, not | |
including the tests. Since TestML is a <strong>language</strong>, 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 <a | |
href="http://testml.org/specification/language/">TestML | |
Specification</a> 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 <a href="http://github.com/ingydotnet/testml- | |
grammar">YAML data structure</a> and used the same YAML for the Python | |
and Perl implementations. The implementations also use a <a href="http://github.com/ingydotnet/testml- | |
tml">common test suite</a>, 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 | |
<a href="http://perlcabal.org/syn/S05.html">Perl 6 Regexes</a>, 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 | |
expection of Rakudo * 1.0 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 <em>language</em>? 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 <a href="http://pypi.python.org/pypi">their | |
CPAN</a>. I find Python to be even nicer than Perl 6, except for one | |
important part... | |
<big>Perl 6 Regexes</big> | |
<em>Perl 6 Regexes</em> 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 homebaked 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! | |
... <strong>*sigh*</strong> yet another project ... | |
<big>Conclusion</big> | |
<em><strong>Is Perl 6 Ready?</strong></em> It is ready enough for <strong>Rakudo</strong>! | |
<em><strong>Is Rakudo Ready?</strong></em> It is ready enough for <strong>TestML</strong>! | |
<strong>Is TestML Ready?</strong> It is ready enough for an <strong>Acmeist</strong> port of <strong>Perl 6 Regexes</strong>! | |
-- Tags: perl6 testml rakudo ingy acmeism python perl yaml jsync tap testing unittest json parsing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment