BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News LFE Brings Lisp to the Erlang Virtual Machine

LFE Brings Lisp to the Erlang Virtual Machine

This item in japanese

Bookmarks

After 8 years of development, Lisp Flavoured Erlang (LFE) has reached version 1.0, bringing stable support for Lisp programming on the Erlang virtual machine (BEAM). LFE was created by Robert Virding, one of the initial developers of Erlang

LFE is a Lisp–2, i.e. Common Lisp-like, frontend to the Erlang compiler, which means it enables macro-based metaprogramming and favours the use of recursion and higher-order functions. In keeping with Erlang philosophy, LFE adopts a message passing actor model that enforces a “share nothing” paradigm and fully supports pattern matching. Since it generates 100% Erlang compatible code, LFE can coexist seamlessly with vanilla Erlang and applications using the Open Telecom Platform (OTP), a collection of middleware and libraries in Erlang that aim to enable the creation of high-availability, concurrent, scalable architectures.

The following code snippets provide a very basic comparison between Erlang’s and LFE’s syntaxes to define a recursive function to sum the elements of a list:

Erlang:

      sum(L) -> sum(L,0).
      sum([], Total) -> Total;
      sum([H|T], Total) -> sum(T, H+Total).

LFE:

      (defun sum (l) (sum l 0))
      (defun sum
        (('() total) total)
        (((cons h t) total) (sum t (+ h total))))

In Lisps tradition, LFE can be used through a REPL, which makes it easier to play and experiment with the features of the language. The REPL, as well as other facilities for task admin, project creation, and dependency management are provided by the lfetool project. It can be installed through Docker by running: docker pull lfex/lfe, which will include all required parts to create and run LFE projects.

As an additional note worth of consideration, LFE maintainers have undertaken the task of writing an LFE-edition of Gerald Jay Sussman and Hal Abelson’s classic book, Structure and Interpretation of Computer Programs, which is still in preliminary stages.

InfoQ has spoken with Duncan McGreggor, maintainer of lfetool and many LFE libraries, to learn more about the language.

LFE has recently reached version 1.0, after several years of development. What does that mean and how would you evaluate LFE’s stability or readiness for use in production?

Robert has mentioned this before on the LFE mail list and in tweets, but the v1.0 was essentially arbitrary. It has been ready for a 1.0 release for quite some time. In fact, we know of several established companies and a handful of startups that are using LFE in production. A few of these have been using LFE for several years in production. Which makes sense, since LFE compiles to 100% compatible Core Erlang. Erlang has been stable in production for decades.

What are the advantages of using a Lisp-like language on the Erlang virtual machine?

The Lisp advantages are all the ones that people have been saying about Lisp since the 60s: flexibility and versatility (via a REPL, macros, homoiconicity, the ability to easily create DSLs, etc.) Combine this with the decades of related language/library work from the Lisp community that LFE can take inspiration from, and you have pretty impressive resources from which to draw. While that’s true for any modern Lisp, adding the core features of Erlang such as high-concurrency and fault-tolerance, and LFE becomes a bit of a dream come true for Lispers who need to create distributed systems.

Could you share some insights about LFE’s roadmap? What is the pace of development of LFE SICP?

One of the biggest priorities for LFE right now is bringing the docs up to date (consolidation, refresh, supporting multiple versions, making it easier for users/readers to contribute). We have several years worth of related efforts that need to be unified into a single, usable experience for the LFE community members. Lots of work to do there! We’ve got a new design ready to go and are currently exploring content-generation from multiple documentation sources. We’re making slow but steady progress on this, and are hopeful that these efforts will be well-received by the LFE community.

The work on converting SICP to LFE was stalled (due to the work schedule of the primary editor), but that is starting up again, inspired by the recent efforts being made on the docs. Several supporting updates have been made in the last week – expect more content soon!

LFE is available on GitHub and can be installed from Homebrew, Docker, or source.

Rate this Article

Adoption
Style

BT