Note: this is not a technical post. It is a shy love letter to language design and compilers

I spent yesterday afternoon programming in a language that does not yet exist.

I set a goal of designing and implementing a language in an afternoon, and making a game in that language. At RC we are encouraged to work at the edge of our abilities, and in week three we try to push way beyond that edge on Impossible Stuff Day. When I started RC, there were two realms of study I was interested in: I wanted to write software to make hardware do things (designing a small CPU or building a robot) and I wanted to do something with compilers, maybe write a tiny language. I’ve started on the hardware end of things with making TinyPong for the micro:bit-v2 and working through Nand2Tetris, but I hadn’t approached the other side of my interests beyond reading the start of Crafting Interpreters.

My goals for this moonshot day:

  • Design a language
  • Write a compiler for it
  • Develop a game in that new language

Simple, right?

Before starting on this endeavor I revisited a book I haven’t opened in a very long time.

Compilers:Principles, Techniques, & Tools

It has a dragon wearing a purple sweater that reads "Complexity of Compiler Design" o n the front -- how could I not love it?

Compilers was my favorite course in college. As I recall, the class was heavy on theory and abstract representations, with only a few exercises using yacc and flex.

My approach for the day was to first try writing in this new language, then describe the formal grammar, then write a lexical analyzer for it, and hopefully find my way through the rest as I got there. The only requirement I came in with was that I be able to make games with the language – beyond that, I had no preconceived ideas of what it would be.

I called my language crocus for the afternoon (there is a crocus language already, so I’ll have to come up with another name). The crocus is an important piece of imagery for me this year, and it felt fitting for a first language attempt as well: emerging as the first signs of life after winter, even when there is still snow from the winter preceding.

As I wrote in crocus for the first time, I thought about what the language could be capable of while also working through the logic of the individual programs, and how the language might map to ASTs and whether it matched itself. How code maps to memory and makes use of resources is always a consideration when I program, but possibilities open up when it hasn’t yet been implemented. The language and its compiler do not yet have limitations, in style or efficiency.

// a sample visual game in crocus

use slib, game

enclose, to selves {

once {
    always, until exception && minding State {
        set background, scene;
        resolve consequences, minding change;

My coding became playful. I tried on many different styles, making the language more verbose or concise, poetries both flowing and brusque. Crocus trended towards being static and object-oriented, but it didn’t stay there. I danced between lines of code and their abstractions, rewriting as I played with formal notation and disambiguation. As the afternoon unfolded, so did I, until suddenly the welling in my chest became tears, overcome with vastness, deep joy, and relief. I haven’t sought this part of myself in a very long time, afraid that if I looked it wouldn’t be there anymore – but it was, just as happy and relieved to be found again.

Ink drawing of layered clouds above a blank expanse

I drew this as I felt through the aftermath of my afternoon developing crocus

I didn’t finish crocus in a day. I expect to dabble in a variety of language attempts over the next nine weeks, and maybe one will become a large project.