Wiki: How to make a Lisp interpreter in 56 languages

For agents: Markdown version · Wiki index · Explore

Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.

Summary

This talk explores the “Make A Lisp” project, an educational initiative centered around implementing a Lisp dialect across dozens of programming languages. The speaker discusses the core components required to build a functional interpreter, ranging from basic I/O and parsing to advanced features like tail call optimization and macros. The audience learns how language interpreters can be built in unusual or even non-traditional environments, demonstrating the universal principles of programming language design.

Key points

  • 0:00 The speaker introduces the “Make A Lisp” project, an educational framework created by Joel Martin for implementing a simple Lisp dialect in various languages.
  • 0:00 Building the base interpreter requires reading input, printing output, parsing data into an abstract syntax tree, and serializing it back.
  • 1:21 To handle loops without stack overflow, the project relies on tail call optimization to transform recursive calls into jumps.
  • 1:21 Macros allow extending the language by writing Lisp functions that process other Lisp code as input and output.
  • 3:09 The Lisp dialect is powerful enough to implement an interpreter of itself, known as self-hosting.
  • 3:09 A compiler was also developed to translate the Lisp dialect into LLVM intermediate representation, generating native binaries.

Takeaways

  • Understand the core components needed to build a simple interpreter, including parsers and evaluators.
  • Learn how tail call optimization enables recursion without exhausting memory.
  • Explore the concept of self-hosting by implementing an interpreter in its own language.

Questions this talk answers

  • How do you implement an interpreter for a Lisp dialect from scratch?
  • What is tail call optimization and how does it replace traditional loops?
  • How can you achieve self-hosting in a custom programming language?

Technologies

Python, Make, Tcl, PostgreSQL, Visual Basic, JavaScript, Java, PostScript, LLVM, COBOL

Tags

compilers, interpreters, lisp, programming languages, recursion