Clojure on Fennel Part One: Persistent Data Structures

Dev brings Clojure vibes to Lua—fans swoon, skeptics say “just use Clojure”

TLDR: A new compiler aims to run Clojure code on Fennel/Lua and is being rebuilt with faster, immutable data structures to fix early performance issues. The community is split between excitement over bringing Clojure’s strengths to Lua and skeptics demanding benchmarks or asking why not just use Clojure—memes included.

A solo dev just dropped “ClojureFnl,” a compiler trying to run Clojure code on Fennel (a tiny Lisp that runs on Lua), and the comments instantly lit up. The big plot twist: the first attempt at “unchangeable” data (think Lego blocks that share pieces instead of copying everything) was slow, so the dev is rebuilding it with smarter, share-more-copy-less structures. Translation: make it fast without breaking the “never mutate” magic.

Fans rushed in to hype Clojure’s secret sauce. One standout cheer: “Clojure’s immutable HAMTs are still a superpower,” a nod to the clever map/set tech that helps everything run fast. The vibe: if this lands, Lua land gets a dose of Clojure’s legendary stability. But the pushback was loud too: performance hawks want proof, and practical folks asked the eternal question—why not just write Clojure? Cue the “show me benchmarks” chorus.

And because the internet can’t resist, the HAMT (Hash Array Mapped Trie) jokes arrived hot and ready: ham emojis, “HAMT sandwich” memes, and a running gag about “Lisp on Lua on Lisp” being software Inception. It’s equal parts ambitious and audacious—with the community split between cheering the experiment and side‑eyeing the complexity. Either way, this thread sizzled.

Key Points

  • The author built fennel-cljlib to bring a subset of Clojure’s core features to Fennel/Lua, including laziness, immutability, testing, and a core.async port.
  • A new Clojure-to-Fennel compiler, ClojureFnl (v0.0.1), can compile many .cljc files but has limited runtime due to incomplete standard library support.
  • The initial immutability approach (itable and immutableredblacktree.lua) used copy-on-write with metatables, causing severe performance issues.
  • Maps suffered less from copy-on-write due to partial copying, whereas arrays performed poorly; transients helped but were insufficient.
  • Clojure’s persistent data structures (Persistent HAMT, bit-partitioned tries, immutable red-black trees) are identified as necessary replacements; existing Lua HAMT implementations like ltrie have gaps.

Hottest takes

"Clojure's immutable HAMTs are still a superpower" — xeubie
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.