Jeff Bezanson's Femtolisp Challenges Notions of Minimal Lisp Implementations
#Dev

Jeff Bezanson's Femtolisp Challenges Notions of Minimal Lisp Implementations

Startups Reporter
2 min read

Julia co-creator Jeff Bezanson unveils femtolisp, a sub-150kb Scheme implementation that delivers surprising performance and complete feature parity while critiquing modern Lisp fragmentation.

Featured image

When Julia co-creator Jeff Bezanson set out to build "the fastest lisp interpreter I could in under 1000 lines of C," he didn't expect it to evolve into a full-featured Scheme dialect. Yet femtolisp now stands as a 150kb implementation that outperforms many non-compiled Schemes while packing improbable completeness into its tiny footprint.

The project began as an exercise in minimalism but grew to include vectors, strings, gensyms, backquote, exception handling, circular structure handling, hash tables, and C interop similar to Python's ctypes. Remarkably, femtolisp achieves competitive speeds despite implementing core functions like filter and for-each in the language itself rather than relying on C optimizations.

At its architectural core lies a bytecode compiler written in femtolisp that produces human-readable bytecode—represented as low-ASCII strings—that remains editable and serializable. The VM executes this bytecode with proper tail recursion, a feature Bezanson defends against critics: "All you have to do is keep track of whether you're in tail position, which can be done very cheaply." Reference implementations in the tiny subdirectory demonstrate this efficiency without sacrificing lexical scope.

With just 12 builtin special forms and 33 primitive functions, femtolisp embodies a philosophy of radical simplicity. Bezanson prioritizes having "each concept implemented in just one place," arguing this approach yields higher reliability through reduced complexity. The codebase explicitly avoids what he calls "spurious novelties"—changes that break compatibility without tangible benefits. "How does it help to remove backquote?" he challenges, citing examples of dialects that alter quote syntax or ban dotted lists while introducing "weird implicit behaviors."

Notably, femtolisp includes often-overlooked Lisp essentials: read macros (#.), backreferences, properly escaped symbol names, and readable circular structure printing. Bezanson wryly notes: "If you're going to waste everybody's time with yet another lisp, at least do it right damnit."

The self-contained system bundles ios—a C library replacement for stdio—and supports UTF8 streams alongside its compacting garbage collector. Despite its completeness, Bezanson acknowledges the project's niche status: "This is what I do for fun, because it is the exact opposite of the kind of thing people will pay for: an obscure implementation of a programming language everybody hates."

For developers exploring language implementation, femtolisp offers a masterclass in density-conscious design. Its existence questions whether contemporary language fragmentation stems from necessary innovation or unnecessary reinvention, all while delivering a surprisingly capable Scheme in less space than most image files.

Comments

Loading comments...