Monday, August 16, 2010

Parrot and PIR: The best tool you don't use

For over 10 years now, many eyes have been on Perl 6, watching and waiting for it to be stable enough to use. Its promise is vast. Powerful "rules" will transform complicates parsing tasks into trivial libraries; A multi-method OO system like Common Lisp, but without the syntactic hurdles of learning to live with Lisp, a typed dynamic language that doesn't tie you down to type management. All of these features seem like the white whale of Melville's story, and yet they all exist today in a usable and stable form. Why doesn't anyone know about this? Well, I'm here to change that.

Parrot, the virtual machine first intended for Perl 6 and developed in parallel with that project, has the underlying mechanisms for everything Perl 6 wants to accomplish. It even has a pseudo-Perl 6 language called NQP (Not Quite Perl) for writing rules and other Perl 6-like functionality. But one thing slowing people down, to date, has been the lack of a coherent tutorial on using Parrot as a general purpose programming tool. Enter Parrot Babysteps. This Web tutorial (which is also a Github project) aims to teach people to program with Parrot. Its examples range from the typical and trivial, "Hello world" to a star catalog manager.

Parrot code is anything but beautiful. The language is modeled on assembly and is designed to be easily transformed into machine code via a JIT compiler, so don't expect it to be full of syntactic sugar like Perl. On the other hand, the combination of JIT compilation and high level constructs gives you the kind of power and performance that even Java is hesitant to offer.