All Projects → bakpakin → Fennel

bakpakin / Fennel

Licence: mit
Lua Lisp Language

Programming Languages

lua
6591 projects
language
365 projects
lisp
113 projects

Labels

Projects that are alternatives of or similar to Fennel

Contracode
Contrastive Code Representation Learning: functionality-based JavaScript embeddings through self-supervised learning
Stars: ✭ 66 (-94.61%)
Mutual labels:  compiler
Akilang
A compiler for a simple language, built with Python and LLVM
Stars: ✭ 71 (-94.2%)
Mutual labels:  compiler
Delta
Programming language focused on performance and productivity
Stars: ✭ 77 (-93.71%)
Mutual labels:  compiler
Gatsby Starter Default
The default Gatsby starter
Stars: ✭ 1,154 (-5.8%)
Mutual labels:  compiler
Seeless
C IDE for iOS
Stars: ✭ 71 (-94.2%)
Mutual labels:  compiler
Lens
Language for Embeddable .NET Scripting
Stars: ✭ 71 (-94.2%)
Mutual labels:  compiler
Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (-6.45%)
Mutual labels:  compiler
Rubyx
RubyX compiles ruby to binary (in ruby), hoping to be that X times faster
Stars: ✭ 78 (-93.63%)
Mutual labels:  compiler
Jit Compiler
JIT compiler in Go
Stars: ✭ 70 (-94.29%)
Mutual labels:  compiler
Vab
V Android Bootstrapper
Stars: ✭ 77 (-93.71%)
Mutual labels:  compiler
Kai
An expressive low level programming language
Stars: ✭ 68 (-94.45%)
Mutual labels:  compiler
Jsweet
A Java to JavaScript transpiler.
Stars: ✭ 1,167 (-4.73%)
Mutual labels:  compiler
Mini Interpreter
A Simple Scripting Language
Stars: ✭ 72 (-94.12%)
Mutual labels:  compiler
Orange
The Orange programming language
Stars: ✭ 67 (-94.53%)
Mutual labels:  compiler
Yapypy
Yet another Python Python
Stars: ✭ 77 (-93.71%)
Mutual labels:  compiler
Compiler Explorer
Run compilers interactively from your web browser and interact with the assembly
Stars: ✭ 9,844 (+703.59%)
Mutual labels:  compiler
Online Compiler
This is an online compiler that can compile and run C\C++ And Java Program. This online compiler is a part of my 5th semester project "RUET Online Judge" . Developed By Ashadullah Shawon
Stars: ✭ 71 (-94.2%)
Mutual labels:  compiler
Tiger
Tiger Compiler from "Modern Compiler Implementation in ML" by Andrew W. Appel
Stars: ✭ 77 (-93.71%)
Mutual labels:  compiler
Idiolisp
A statically typed functional programming language
Stars: ✭ 78 (-93.63%)
Mutual labels:  compiler
Ts Transform Css Modules
Extract css class names from required css module files for TypeScript
Stars: ✭ 75 (-93.88%)
Mutual labels:  compiler

Fennel

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

  • Full Lua compatibility - You can use any function or library from Lua.
  • Zero overhead - Compiled code should be just as or more efficient than 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.

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 API listing shows how to integrate Fennel into your codebase
  • 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))

Building Fennel from source

Building Fennel from source allows you to use versions of Fennel that haven't been released, and makes contributing to Fennel easier.

To build Fennel from source

  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. Copy or link the fennel script to a directory on your $PATH, such as /usr/local/bin

Note: If you copied the fennel script to one of the directories on your $PATH, then you can run fennel filename.fnl to run a Fennel file anywhere on your system.

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
  • Opt-in mutability for local variables
  • Opt-in arity checks for lambda functions
  • Pattern matching
  • Ability to extend the syntax with your own macros and special forms

Differences from other lisp languages

  • Its VM can be embedded in other programs with only 180 kB
  • 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

(Obviously not all these apply to every lisp you could compare Fennel to.)

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

License

Copyright © 2016-2021 Calvin Rose and contributors

Released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].