HeadlinesBriefing favicon HeadlinesBriefing.com

femtolisp: Lightweight Scheme Lisp Implementation

Hacker News •
×

femtolisp is a lightweight, robust Scheme-like Lisp implementation that began as an experiment to create the fastest interpreter possible in under 1000 lines of C. The project has evolved into a comprehensive system featuring a compacting garbage collector, bytecode compiler, and VM, all while maintaining exceptional performance. With 1.6k stars on GitHub, it has attracted significant attention from the Lisp community.

The implementation includes powerful features typically found in larger systems: vectors, strings, gensyms, backquote, exceptions, and hash tables. Notably, femtolisp supports circular structure printing and reading, proper tail recursion, and direct C data type integration similar to Python's ctypes. The core API remains deliberately minimal with just 12 builtin special forms and 33 builtin functions, emphasizing simplicity and elegance over feature bloat.

What sets femtolisp apart is its speed ranking among the fastest non-native-compiled Scheme implementations despite many primitives being written in the language itself rather than C. The bytecode is human-readable and first-class, stored as normal low-ASCII strings. The project prioritizes code conciseness and reliability, with each concept implemented in just one place to minimize bugs. At only 150kb and highly self-contained, femtolisp demonstrates that powerful Lisp implementations don't require massive codebases, challenging the notion that speed and proper tail recursion are mutually exclusive.