Allison Randal‘s session, Programming Parrot, is the first, and likely the last, session I have attended at SCALE. I’m primarily a Perl programmer and only wear my sysadmin hat because I’m paid by my employer to do so. Also, being a computer science nerd, I also really enjoy compiler theory, so here I am.
Jumping right into the talk, Allison started off with the general idea of Parrot. It is a virtual machine (VM) meant to be a target for multiple (or all, really) dynamic languages. Think Perl, Python, Ruby, TCL, Lua, etc. Much like Perl itself, the overarching idea is to provide tools to make the act of writing compilers not only possible, but relatively easy.
When Parrot started, some seven years ago, people laughed when they said it would be a VM for dynamic languages. The JVM and .NET VM were all the rage at the time, and they are targeted at static languages. Today, those same people are touting how their VMs contain support for dynamic languages.
The rest of the session was a general overview of Parrot’s features and functionality. In brief,
- Similar to .NET, Parrot would allow any language to use libraries written in any other;
- Parrot is a register-based virtual machine, instead of the traditional stack-based design;
- Continuation objects are used to pass call state, instead of the usual method of pushing onto a call stack;
- PASM, the Parrot virtual machine’s assembly language;
- PIR, a layer on top of PASM, intended to be more programmer-friendly;
- NQP, an even higher layer, implementing many of the features from high level dynamic languages (Not Quite P(erl|ython|HP|ruby));
Following this simple, but educational, overview, Allison gave some examples for how to use the Parrot tools to write a Python compiler. This is something the Parrot team has, of course, already done. It’s called Pynie (a bit of an inside joke&emdash;see Ponie and Punie). It’s not really that much code to implement, either. Certainly not compared to what I wrote to parse “Turing” in college using Lex, Yacc, and lots of C code. It just goes to show how powerful the Parrot tools are.
I had read about much of this before, but unused information tends to slip away when not used. It was nice to have a refresher course for the overall architecture of the system. It’s all very much clearer now. I’m looking forward to finding a use for Parrot.
[tags]SCALE, Parrot[/tags]