Discover Fennel: A Lisp‑Based Language for Lua Lovers and Game Creators
Fennel is a Lisp‑style programming language built on Lua that offers zero‑overhead compilation, full Lua compatibility, compile‑time macros, and easy embedding, making it ideal for creating games and art in environments like TIC‑80, while preserving the simplicity of s‑expressions.
This month’s language spotlight is Fennel, a Lisp that runs on Lua and brings the power of s‑expressions to Lua developers.
Fennel uses prefix notation and parentheses, so an addition is written as (+ 2 2) instead of 2 + 2.
The design echoes the original 1950s Lisp ideas: simple syntax, easy code writing, and a macro system that lets you transform code at compile time.
Macros act like functions that rewrite S‑expressions, enabling language extensions without creating a brand‑new language.
Getting Started
You can run Fennel directly in TIC‑80 to build games and generative art without any installation.
Key Features
Fully compatible with Lua: call any Lua function or library from Fennel and vice versa.
Zero overhead: compiled code runs as efficiently as hand‑written Lua.
Compile‑time macros: no runtime dependency on Fennel.
Embeddable: single‑file library or executable that can be embedded for runtime extensibility and interactive development.
Sample Code
;; Sample: read the state of the keyboard and move the player accordingly
(local dirs {:up [0 -1] :down [0 1] :left [-1 0] :right [1 0]})
(each [key [dx dy] (pairs dirs)]
(when (love.keyboard.isDown key)
(let [[px py] player
x (+ px (* dx player.speed dt))
y (+ py (* dy player.speed dt))]
(world:move player x y))))Any environment that can run Lua can also run Fennel code.
Community
The source repository lives on Sourcehut with a read‑only mirror on GitHub; discussions happen on the mailing list, Libera.Chat, and the Matrix #fennel channel.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
