Lisp Flavoured Erlang
From ErlangCentral Wiki
LFE, or Lisp Flavoured Erlang, is a Lisp syntax front-end to the Erlang compiler. LFE is a Lisp-2, like Common Lisp, and comes with a REPL (shell) for use with interactive coding. LFE allows one to write Erlang/OTP apps in a Lisp language, with full access to the BEAM ecosystem.
LFE-based projects coexist seamlessly with Core Erlang/OTP. As such, code written in LFE can freely be used together with modules written in other BEAM languages such as Erlang and Elixir. The reverse applies too: LFE libraries and services may be used by other Erlang/OTP projects.
A few of LFE's features include:
- . Homoiconicity
- . Lisp macros
- . Actor model
- . Async
- . High concurrency
- . Pattern matching
- . Functional programming language
- . 100% interop with Erlang/OTP
- . Interop with Java via JInterface and Erjang
More features are presented here.
LFE has a Quick Start guide. In 4 short pages, you will:
- . Download and install lfetool.
- . Create new LFE projects with a single command.
- . Run LFE unit tests, see errors, and correct them.
- . Learn to use the LFE REPL (shell).
- . See what Erlang/OTP functions look like in LFE.
- . Learn where to go next to dive in deeper.
There are also a growing number of examples on Rosetta Code's LFE section.
Here is a quick bit of code, an LFE translation of Joe Armstrong's favourite Erlang program:
(defmodule joes-fav (export all)) (defun universal-server () (receive ((tuple 'become server-function) (funcall server-function)))) (defun factorial ((0) 1) ((number) (* number (factorial (- number 1))))) (defun factorial-server () (receive ((tuple sender number) (! sender (factorial number)) (factorial-server)))) (defun run-it () (let ((pid (spawn #'universal-server/0))) (! pid (tuple 'become #'factorial-server/0)) (! pid (tuple (self) 50))) (receive (data data)))
Here are some additional resources for the interested reader:
- . 'develop' Github repo - all the latest happens in this branch
- . The main documentation site
- . The LFE Github org that collects LFE projects into a single location (there are several pages of projects in this org -- check them out!).
- . Mail list (Google Groups)
- . Twitter account
- . LFE Daily - a paper.li daily news site for the world of LFE
- . #erlang-lisp on the Freenode.net IRC network
- . LFE videos on Erlang Central
- . Examples on Rosetta Code's LFE section
- . Fairly regular LFE blog posts by an LFE community member.
- . Old page for LFE on TrapExit