femtolisp: A lightweight, robust, scheme-like Lisp implementation

Published: (February 23, 2026 at 07:38 AM EST)
3 min read

Source: Hacker News

Join the chat at https://gitter.im/FemtoLisp/flisp

…a purely symbolic gesture…

This project began with an attempt to write the fastest Lisp interpreter I could in under 1,000 lines of C. It snowballed from there as I kept trying to see if I could add powerful features with minimal code. At the same time I assembled a library of some of my favorite C code (by myself and others) to use as a base for a standard library. This includes ios, a replacement for parts of C’s stdio that adds more flexible features.

Before you say “oh no, another Lisp”, consider the following: femtolisp is about 150 KB, is very self‑contained, and has the following features:

  • vectors, strings, gensyms
  • backquote
  • exceptions
  • printing and reading circular/shared structure
  • all values can be printed readably
  • pretty‑printing
  • hash tables
  • support for directly using C data types ala Python’s ctypes
  • equal and ordered comparison predicates that work on circular structure
  • proper tail recursion
  • I/O and memory streams with UTF‑8 support
  • highly compatible with Scheme, including some R6RS features
  • simple, well‑organized, powerful API with as few functions as possible
  • compacting GC

…and it is fast, ranking among the fastest non‑native‑compiled Scheme implementations. It achieves this level of speed even though many primitives (e.g. filter and for‑each) are written in the language instead of C. femtolisp uses a bytecode compiler and VM, with the compiler written in femtolisp. Bytecode is first‑class, can be printed and read, and is “human readable” (the representation is a string of normal low‑ASCII characters).

femtolisp is a simple, elegant Scheme dialect. It is a Lisp‑1 with lexical scope. The core consists of 12 builtin special forms and 33 builtin functions.

Design Goals

  • Conciseness: Each concept is implemented in just one place, making the system easy to understand and modify. Fewer places for bugs means higher reliability. See torture.scm for examples of a small core of generically useful features that work really well.
  • Correctness: Many Lisp implementations omit obscure but critical features such as read macros like #., backreferences, gensyms, and properly escaped symbol names. If you’re going to create another Lisp, at least do it right.
  • Stability: Avoid spurious novelties. Some “shiny new” dialects change syntax arbitrarily (e.g., removing backquote, altering quote, disallowing dotted lists), which harms compatibility without real benefit.
  • Performance: Proper tail recursion is often misunderstood as a speed penalty. The “tiny” subdirectory or the “interpreter” branch shows a pure s‑expr interpreter with efficient proper tail calls that remains hard to beat for speed while retaining lexical scope.

Implementation Notes

  • The project is mostly a matter of style. Looking at the code will reveal the philosophy behind it.
  • This work is done for fun, as an exact opposite of commercial language implementations—an obscure implementation of a programming language many consider “unpopular”.

0 views
Back to Blog

Related posts

Read more »

Steel Bank Common Lisp

About Steel Bank Common Lisp SBCL is a high performance Common Lisp compiler. It is open source / free software, with a permissive license. In addition to the...

Created a Mouse Mover for Mac

Repository: https://github.com/zhangyaoxing/toolkithttps://github.com/zhangyaoxing/toolkit Overview Moving the mouse cursor or windows across multiple monitors...