Monkey Lang: an interpreter written by hand

I never took the opportunity in college to take a course on compilers, so I wanted make up for it by following along with the book Writing an Interpreter in Go. It’s not a quite a compiler, but an interpreter is pretty close, right? I wanted put a spin on things, so instead of writing the project in garbage-collected Go, I wrote it in memory-unmanaged Zig!

Monkey Lang includes:

  • integers
  • booleans
  • strings
  • functions as expressions (closures)
  • if-else control flow
  • implicit and explicit returns

Here’s an example of the syntax:

let version = 1;
let name = "Monkey programming language";
let myArray = [1, 2, 3, 4, 5];
let coolBooleanLiteral = true;

let awesomeValue = (10 / 2) * 5 + 30;
let arrayWithValues = [1 + 1, 2 * 2, 3];

This is my first Zig project to break the 1,000 LoC mark, so I’m sure there’s plenty of room for improvement. Let me know what constructive criticism you have!

10 Likes