Retour au classement

bakpakin/Fennel

Fennelfennel-lang.org

Lua Lisp Language

lualispcompilerlanguage
Croissance des étoiles
Étoiles
2.7k
Forks
131
Croissance hebdomadaire
Issues
3
1k2k
sept. 2016déc. 2019avr. 2023juil. 2026
README

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.

  • Full Lua compatibility - You can use any function or library from Lua.
  • Zero overhead - Compiled code should be just as efficient as hand-written Lua.
  • Compile-time macros - Ship compiled code with no runtime dependency on Fennel.
  • Embeddable - Fennel is a one-file library as well as an executable. Embed it in other programs to support runtime extensibility and interactive development.

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

  • The setup guide is a great place to start
  • The tutorial teaches the basics of the language
  • The rationale explains the reasoning of why Fennel was created
  • The reference describes all Fennel special forms
  • The macro guide explains how to write macros
  • The API listing shows how to integrate Fennel into your codebase
  • The style guide gives tips on how to write clear and concise code
  • The Lua primer gives a very brief intro to Lua with pointers to further details

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

  • Syntax is much more regular and predictable (no statements; no operator precedence)
  • It's impossible to set or read a global by accident
  • Pervasive destructuring anywhere locals are introduced
  • Clearer syntactic distinction between sequential tables and key/value tables
  • Separate looping constructs for numeric loops vs iterators instead of overloading for
  • Comprehensions result in much more succinct table transformations
  • Opt-in mutability for local variables
  • Opt-in nil checks for function arguments
  • Pattern matching
  • Ability to extend the syntax with your own macros

Differences from other lisp languages

  • Its VM can be embedded in other programs with only ~200kb
  • Access to excellent FFI
  • LuaJIT consistently ranks at the top of performance shootouts
  • Inherits aggressively simple semantics from Lua; easy to learn
  • Lua VM is already embedded in databases, window managers, games, etc
  • Low memory usage
  • Readable compiler output resembles input
  • Easy to build small (~250kb) standalone binaries
  • Compilation output has no runtime dependency on Fennel

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.5 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-2025 Calvin Rose and contributors, released under the MIT license.

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

The file style.txt is copyright © 2007-2011 Taylor R. Campbell, 2021-2025 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/

Dépôts similaires
neovim/neovim

Vim-fork focused on extensibility and usability

Vim ScriptOtherneovimc
neovim.io
101.3k7k
coolsnowwolf/lede

Lean's LEDE source

COtherledelua
31.5k19.2k
NvChad/NvChad

Blazing fast Neovim framework providing solid defaults and a beautiful UI, enhancing your neovim experience.

LuaGNU General Public License v3.0nvimneovim
nvchad.com
28.4k2.2k
nvim-telescope/telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.

LuaMIT Licenseneovimlua
19.6k956
LunarVim/LunarVim

🌙 LunarVim is an IDE layer for Neovim. Completely free and community driven.

LuaGNU General Public License v3.0neovimvim
lunarvim.org
19.3k1.5k
cocos2d/cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.

C++cocos2dcocos2d-x
cocos.com/en/cocos2d-x
19.1k7.1k
Hammerspoon/hammerspoon

Staggeringly powerful macOS desktop automation with Lua

Objective-CMIT Licensemacosobjective-c
hammerspoon.org
15.8k700
AstroNvim/AstroNvim

AstroNvim is an aesthetic and feature-rich neovim config that is extensible and easy to use with a great set of plugins

LuaGNU General Public License v3.0vimlua
astronvim.com
14.4k954
spotify/annoy

Approximate Nearest Neighbors in C++/Python optimized for memory usage and loading/saving to disk

C++Apache License 2.0c-plus-pluspython
14.3k1.2k
dense-analysis/ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support

Vim ScriptBSD 2-Clause "Simplified" Licenselintervim
14k1.5k
luanti-org/luanti

Luanti (formerly Minetest) is an open source voxel game-creation platform with easy modding and game creation

C++Otherc-plus-plusvoxel
luanti.org
13.3k2.4k
nmap/nmap

Nmap - the Network Mapper. Github mirror of official SVN repository.

COtherc-plus-pluslua
svn.nmap.org
13.2k2.9k