Needed 1+1, Built a Functional Programming Language

September 16, 2026 • 13 min read

I was given a data structures problem of converting an arithmetic expression into a binary tree. Naturally, I decided to build an evaluator.

A few days later I implemented closures, a garbage collector, a custom memory allocator, a REPL, an FFI, and a whole bunch of other stuff in C.

THE DATA STRUCTURES ASSIGNMENT

The problem was: Evaluate 1 + 1 + 1 to 3 using a binary tree. The operator becomes the root, with its two operands as children. Evaluating recursively collapses nested + expressions.

One way to represent operations is different cases in an expression type (Add, Sub, Mul, Div). But they all take two expressions and produce one — so why should the evaluator care which operation it is? Represent expressions as: