Home

Awesome

Fennel

Fennel is a lisp that compiles to Lua. It aims to be easy to use, expressive, and has almost zero overhead compared to writing Lua directly.

At https://fennel-lang.org there's a live in-browser repl you can use without installing anything. At https://fennel-lang.org/see you can see what Lua output a given piece of Fennel compiles to, or what the equivalent Fennel for a given piece of Lua would be.

Documentation

For more examples, see the cookbook on the wiki.

The changelog has a list of user-visible changes for each release.

Example

Hello World

(print "hello, world!")

Fibonacci sequence

(fn fib [n]
  (if (< n 2)
      n
      (+ (fib (- n 1)) (fib (- n 2)))))

(print (fib 10))

Differences from Lua

Differences from other lisp languages

Why not Fennel?

Fennel inherits the limitations of the Lua runtime, which does not offer pre-emptive multitasking or OS-level threads. Libraries for Lua work great with Fennel, but the selection of libraries is not as extensive as it is with more popular languages. While LuaJIT has excellent overall performance, purely-functional algorithms will not be as efficient as they would be on a VM with generational garbage collection.

Even for cases where the Lua runtime is a good fit, Fennel might not be a good fit when end-users are expected to write their own code to extend the program, because the available documentation for learning Lua is much more readily-available than it is for Fennel.

Resources

Building Fennel from source

This requires GNU Make and Lua (5.1-5.4 or LuaJIT).

  1. cd to a directory in which you want to download Fennel, such as ~/src
  2. Run git clone https://git.sr.ht/~technomancy/fennel
  3. Run cd fennel
  4. Run make fennel to create a standalone script called fennel
  5. Run sudo make install to install system-wide (or make install PREFIX=$HOME if ~/bin is on your $PATH)

If you don't have Lua already installed on your system, you can run make fennel-bin LUA=lua/src/lua instead to build a standalone binary that has its own internal version of Lua. This requires having a C compiler installed; normally gcc.

See the contributing guide for details about how to work on the source.

License

Unless otherwise listed, all files are copyright © 2016-2024 Calvin Rose and contributors, released under the MIT license.

The file test/faith.fnl is copyright © 2009-2023 Scott Vokes, Phil Hagelberg, and contributors, released under the MIT license.

The file style.txt is copyright © 2007-2011 Taylor R. Campbell, 2021-2023 Phil Hagelberg and contributors, released under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License: https://creativecommons.org/licenses/by-nc-sa/3.0/