2025-09-17: AIFPL: an AI functional programming language

Published: 2025-09-17

A few weeks ago I had a random thought that maybe I could implement the current calculator code with something more powerful.

The current calculator was originally code around the Python eval function but that was very much unsafe. To make it safe I had Claude build a custom expression evaluator instead.

As a model, this approach had worked really well, but I've been thinking a lot about future capabilities and it occurred to me that they will likely need support for more general purpose programming. Trying to do this as a subset of Python seemed like a bad idea because Python is designed to be procedural and so building "functional" Python seemed like it would be overly-complex.

The reason I'm interested in creating something functional, as opposed to procedural, is because I want a language that an LLM can use to safely build quite complex logic, but where it does not have any means to express side effects that might in turn lead to a security risk. Instead, this language would be designed to only allow a single input (an expression to be evaluated), and a single output (the result of the evaluation). These aspects would be provided to the interpreter (and potentially a compiler in the future) by an LLM during a tool call, and returned to it in the tool response.

I couldn't think of a nice name for this (unlike Metaphor), so this is the uninspiring name "AIFPL", short for AI functional programming language.

The language is S-expression-based and works as a very simplified Scheme (Lisp).

The absolutely insane thing has been to watch how fast the LLM has built me this language. To get to functional parity with the original calculator tool took about 30 minutes. We've now moved way past that and have added string operations, booleans, and lists. We've also got conditionals with lazy evaluation.

At each point there was a discussion with the AI about the design choices that I wanted to make and why, and it continuously updated the language spec and the AI tool description!

While I've not yet put in place the test framework, the LLM has generated a series of point test programs to check things are working correctly, and then to fix them where they weren't right.

Claude running a test program, then fixing the faults
Claude running a test program, then fixing the faults