Introduction to the Roc Compiler

Reading Time: 3 minutes

I’ve written from time to time about compilers on this blog. I started reading Bob Nystrom’s Crafting Interpreters (and writing about it for you) two years ago, and this year I celebrated my birthday by taking Dave Beazley’s compilers course (and again writing about it for you!)

Eventually I decided (or maybe fate decided) that I needed to try out this compiler thing for myself. I met Richard Feldman at Strangeloop, who convinced me to join the team building the compiler for Roc.

The roc is an enormous legendary bird of prey in the popular mythology of the Middle East, according to Wikipedia.

Roc is a (more or less) functional programming language with a compiler written in Rust that targets, for the most part, LLVM (although there are staright-to-assembly and web assembly backends in development).

I’m not here to sell you on writing Roc. In fact, right now, you sort of can’t. It’s not open-source yet, chiefly because it’s not ready. But that doesn’t disqualify it from joining live-stream fodder, as far as I’m concerned.

Besides, the Roc compiler includes a number of choices about How to Do Things that differs from, say, this diagram from Crafting Interpreters:

Compiler Mountain

Talking through those choices, at a high level, seemed like a good opportunity to introduce new contributors to the compiler, and to exemplify for passers-by the degree to which compiler design, while based on a set of guiding principles, has subjective elements to it. Different compiler teams might design compilers differently based on different assessments of tradeoffs around performance, code base organization, implementation simplicity, or flexibility for later changes.

Anyway, I spent 37 minutes talking through the Roc compiler at a high level in video format. Even if you have no intention of writing Roc, I’m hopeful that this short walkthrough elucidates some of the tradeoffs behind “standard” and “nonstandard” compiler design decisions.

Additional resources I mention in the video description:

If you liked this piece, you might also like:

The compilers course series, of course!

This post about engineering for edge cases, which I think about a lot in the context of compiler design

This piece on documentation, which is scarcely related to compilers but a piece I think might help you nonetheless

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.