Things left unsaid…

In my copious spare time I’m working on a programming language called “Close.” It’s a C-like systems programming language targeted at the Parrot VM.

Now, I’m not a compiler guy. But I don’t have to be. Because Parrot comes with the Parrot Compiler Toolkit (PCT), a set of code that can render an Abstract Syntax Tree (AST) into executable code. The result is that I built a grammar using Perl6, then wrote some action methods hooked to the grammar that built the AST. Then I stood back and let PCT do it’s voodoo. The time between starting the project and now has been about 3 weeks, and I was busy with other stuff for 30 percent or so of that.

Okay, that’s cool. Parrot+PCT rocks, as Allison Randal points out. But it’s not my point. The reason I wrote Close was because people were still coding in PIR — Parrot’s version of assembly language — years after starting the project. D’oh! Everybody knows that the first thing you do with a new architecture is develop a C compiler.

Well, somebody had to do it. So I stepped up. I talked a little bit about it at the Parrot Virtual Machine Workshop last week in Pittsburgh, and some other people acted interested. As a result, it’s up on Google code at But the key for me was a conversation I had with Uri Guttman in a hallway at YAPC10 (the conference to which the PVMW was attached).

I showed Uri this code:

void test_foreach()
	pmc the_list = new ResizableStringArray;
	push the_list, "alpha", "beta", "gamma", "delta", "omega";

	pmc new_list = new ResizableStringArray;
	int count = 0;

	foreach (str i: the_list) {
		push new_list, i;

	ok(count, 5, "f/e Iterate over each element");

	count = 0;
	int pass = 1;

	foreach (i : new_list) {
		if (i != the_list[count++]) {
			pass = 0;

	ok(pass, "f/e Same items, same order");

And Uri read through it, figured out what I was doing, and said, “Well, I don’t like your coding style. And I really don’t like single letter variable names, even inside a loop.”

And my first reaction was “Up yours, bud!” But I swallowed that, and then it hit me: I won!

The whole point of implementing Close was to stop writing code that looks like this:

.sub 'uniquereg' :method
    .param string rtype
    unless rtype goto err_nortype
    if rtype == 'v' goto reg_void
    .local string reg
    reg = 'P'
    $I0 = index 'Ss~Nn+Ii', rtype
    if $I0 < 0 goto reg_psin
    reg = substr 'SSSNNNII', $I0, 1
    reg = concat '$', reg
    .tailcall self.'unique'(reg)
    .return ('')
    self.'panic'('rtype not set')

And so what occurred to me was that I showed Uri some code that didn't look like that. It looked like C. And so naturally he read it. And he commented on something that was relevant to him. Not "Gee, I can read your code!" but "Of course I can read your code -- it's C. But I don't like your curly braces."

Win. Win. Win.

Hearing what Uri did not say was the key.

2 Responses to “Things left unsaid…”

  1. Bill Mattocks Says:

    Nice! Writing compilers, eh? Amazing.

  2. Austin Hastings Says:

    It’s not how well the bear dances…

Leave a Reply