Getting LFE

1 Going Plaid

This is a quick-start, a blur of color. You're not going to get very many details here, but you will get to jump into the LFE REPL and see a little code in action.

For those that would enjoy a more gradual introduction (with a bit more Erlang) thus having the time to see the stars (and not just stunning plaid), you may be interested in checking out the User Guide.

1.1 About LFE

LFE, or "Lisp Flavored Erlang", is a Lisp-2 (similar to Common Lisp in that way) that runs on top of the Erlang VM or "BEAM". Started in 2007 and first release in 2008, it is the oldest sibling in the BEAM language family (the others include Elixir, Joxa, Luerl, Erlog, Haskerl, etc.).

As a Lisp-2, LFE has different namespaces for functions and variables. This means you can have a function name help and a variable named help and they won't conflict. Furthermore, LFE has Erlang's notion of arity, so functions with different arity may share the same name. So you could have a function help that took one argument and another function with the same name that took two arguments, and they wouldn't conflict either.

1.2 Many Paths, One Flavour

Before we jump into LFE, though, you'll need to get it. That can be any of many ways, but we'll highlight a few:

  • Homebrew for Mac OS X and Linux
  • The ultra-fast and easy way (using Docker), or
  • The standard way of setting up dependencies and getting the source.

1.2.1 Homebrew

If you are a Homebrew user -- available for both Mac OS X and Linux -- installing LFE is as simple as a single command:

$ brew install lfe

When the pouring is done, you'll have LFE brewed and ready to savour.

1.2.2 Using Docker

If you choose to run LFE in Docker, you can execute the commands below and then skip to the next section, since you'll be done here!

Docker is not only available on Linux, but runs on Windows and Mac OS X (using the boot2docker tool). Getting Docker set up is beyond the scope of this guide, but once you do, getting LFE is just this simple:

$ docker pull lfex/opensuse

Then you'll need to wait for the download to finish.

In the last command, we asked for the openSUSE LFE image, but there are several to choose from on Docker Hub:

  • Arch Linux
  • CentOS
  • Debian
  • openSUSE
  • Oracle Linux
  • Ubuntu

The smallest image is Debian's, so that would likely be the fastest download. Whichever one you choose, you'll need to use the lfex/* name you see on the Docker Hub page linked above.

We'll continue with openSUSE.

Once your LFE Docker image download is completed, you can then start up LFE:

$ docker run -i -t lfex/opensuse lfe

And that's it! You will be running an LFE REPL :-D

You're ready for the next page. (Feel free to read the rest of this one, though!)

1.2.3 From Source

If you decide to take the "from source" path, you'll be cloning the LFE github repo. First, through, you'll need to ensure you have some software installed on your system.

Dependencies
Erlang

First and foremost, you will need Erlang installed.

  • On Mac OS X, this is as easy as executing brew install erlang
  • On Ubuntu apt-get install erlang.

You can also install Erlang from the various pre-built packages provided on the official Erlang download page or from the Erlang Solutions page (which supports many more package types).

For those who have the need of installing multiple versions of Erlang, there is also the kerl project.

make

In order to use LFE, you will be calling make to compile it. To cover your bases, you'll want to make sure you have the basic development tools installed for your platform.

Ubuntu:

$ sudo apt-get install build-essential

CentOS/Fedora:

$ sudo yum groupinstall "Development Tools"

For Mac OS X, you will need to install the "Developer Tools" from the AppStore.

git

You will also need git to continue with this quick-start. If git doesn't come installed on your system and it wasn't installed as part of your systems basic development tools package, you can download it here or install it using your favourite OS package manager.

Cloning LFE

The most recent version of LFE is always available here:

With git and erl in your $PATH, let's download LFE:

$ git clone https://github.com/rvirding/lfe.git
$ cd lfe
$ make

You'll see the output from LFE getting built, and when it's done, we're ready for the next step in our Lispy Space Adventure!

But first, a message from our sponsors ...

1.3 Other Helpful Projects

rebar3

rebar3 is a tool for managing BEAL-language project dependencies, compiling them, and compiling your project's source code. Many recent Erlang projects have a rebar.config file in them, indicating their support of rebar3.

kerl

If you would like to easily have multiple versions of Erlang installed (or be available for installation) on your system, kerl might be the tool for you. If you have used such tools as virtualenv in Python or Ruby's RVM, then you should be quite comfortable with the concepts behind kerl.

Most people don't need to work with multiple versions of Erlang, however; please consider carefully before unnecessarily complicating your development environment.

Next Stop

Ready for some LFE? Next you'll learn how to create a new LFE project with just one command ...