On a complete whim I felt the urge to look into the Lisp programming language. Installation isn't as straightforward as I expected so I have written a small guide outlining the steps I took to get set up.
Unlike most programming languages, there are no universal implementations of Lisp. Lisp is better known as a family of programming languages. This means there are many different "flavours" of Lisp (called dialects) that each bring their own programming styles to the table.
Two popular versions of Lisp are Common Lisp and Scheme. At a first glance the differences between the two are barely noticeable. The differences lie in what features the dialect has and what tools are available to customise the language. The ability to be customised is what makes Lisp stand out.
The free, online version of the Practical Common Lisp book provides a very good introduction to Lips and the components required to get Lisp up and running.
My development environment
Here is what I used when setting up my development environment:
- macOS El Capitan / Linux Mint Cinnamon 19.1;
- Homebrew (when using macOS);
- Emacs 26.3 (version 24 or greater required);
- the Steel Bank Common Lisp (SBCL) compiler; and
- SLIME (Superior Lisp Interaction Mode for Emacs)
As a rule of thumb, all Lisp development, regardless of the environment, will require:
- an editor;
- a Lisp compiler; and
- a SLIME environment.
Emacs is generally the preferred editor for writing Lisp due to the SLIME plugin, which turns Emacs into a fully-fledged Lisp development environment.
Setting up Lisp
Most Mac computers come with Emacs 22 installed but to use the package manager for Emacs, version 24 or higher is required. For macOS, an updated instance of Emacs can be installed with Homebrew using the brew install emacs command.
As a general rule, to make sure the Homebrew version of applications such as
Emacs are loaded instead of the system default, ensure that
/usr/bin in the
There are several ways to install Emacs:
- by installing a Personal Package Archive (PPA);
- by installing via a software manager (e.g. Snapcraft); or
- by compiling from source.
I opted to install via Snapcraft (using the GNU Emacs snap published by Alex Murray) as my instance of Linux Mint came with Snapcraft ready to go.
Install the SBCL compiler
Common Lisp is one of the more straight forward compilers to use when starting out. The SBCL compiler can be used to compile all Lisp code as Common Lisp.
This can also be installed with Homebrew by running brew install sbcl.
SBCL will need to be installed from the source on Linux. To do this:
- download the appropriate binary for the required platform from the SBCL "Downloads" page (I used the Linux AMD64 1.5.6 binary at the time of writing); and
- follow the "Installing a binary" instructions on the SBCL page.
For reference, the installation instructions on the site at the time of writing are:
$ bzip2 -cd sbcl-1.5.6-x86-linux-binary.tar.bz2 | tar xvf - $ cd sbcl-1.5.6-x86-linux $ sh install.sh
Set up MELPA
The package manager in Emacs is called MELPA. Installing MELPA makes installing the remaining required components much simpler.
init.el file under
~/.emacs.d/ and follow the instructions on the
MELPA website to install MELPA.
With MELPA set up the SLIME package can be installed. Load Emacs and run the command runner by typing M-x.1
Depending on the operating system, the combination M-x may not be possible. A key such as Alt or Option will need to be reassigned to act as a Meta key instead. This will depend on the functionality of the command line interface or operating system.
After typing M-x a prompt will display at the bottom. Type package-install and press Enter, followed by slime, followed by Enter again.2
This will look like:
M-x package-install <Enter> slime <Enter>
SLIME will now begin installing. Emacs will have to restarted before SLIME can run; do this by closing Emacs with C-x + C-c and opening it again.
With SLIME installed and Emacs restarted, SLIME can be run by running M-x slime.
A new window will open; congratulations, Lisp is installed and ready to compile.
In Emacs, (and other languages) M refers to the Meta key, which is typically the Alt or Option key. ↩︎
Enter is sometimes written as
RET, such as in the install guide for SLIME. ↩︎