Skip to content

LISP - Environment

Lisp - Modern Development Environment Setup

Section titled “Lisp - Modern Development Environment Setup”

Setting up a modern Common Lisp environment is easier than ever. The key to Lisp development is its interactive nature, centered around the REPL (Read-Eval-Print Loop). This guide focuses on current best practices for a powerful and productive setup.

An implementation is the Lisp compiler and runtime. The most popular choice today is:

  • Steel Bank Common Lisp (SBCL): A high-performance, open-source compiler that is the de-facto standard for new projects. It provides strong type checking and generates fast native code.
  • Clozure Common Lisp (CCL): Another excellent, fast implementation known for its quick compile times and good support on macOS, Linux, and Windows.
  • Embeddable Common Lisp (ECL): Useful for embedding Lisp in C/C++ applications or for building standalone executables.

We recommend starting with SBCL.

The easiest way to install and manage Lisp implementations is with a version manager or your system’s package manager.

Roswell is a Lisp installation/management utility, like nvm for Node.js or pyenv for Python. It simplifies installing implementations, managing scripts, and getting started. Check the official Roswell GitHub page for installation instructions.

# After installing Roswell, install SBCL
ros install sbcl-bin
# Set it as the default
ros use sbcl-bin
# macOS (using Homebrew)
brew install sbcl
# Debian/Ubuntu
sudo apt-get install sbcl
# Arch Linux
sudo pacman -S sbcl

3. Set Up Your Editor for Interactive Development

Section titled “3. Set Up Your Editor for Interactive Development”

Writing Lisp code in a plain text editor is possible, but the real power comes from an editor that integrates with a running Lisp process.

  • Emacs + SLIME or SLY: This is the traditional gold standard. SLIME (Superior Lisp Interaction Mode for Emacs) and its successor SLY provide deep integration, allowing you to compile functions, inspect objects, and debug code, all from your editor, connected to a live Lisp REPL.
  • Visual Studio Code + Alive: A fantastic modern alternative. The Alive extension provides a rich, SLIME-like interactive experience within the popular VS Code editor, making it very accessible for newcomers.

Let’s start a REPL and run some code. Open your terminal and type sbcl.

$ sbcl
This is SBCL ...
* ; The asterisk is the REPL prompt

Now, you can type Lisp expressions, and the REPL will evaluate them and print the result.

* (+ 2 2)
4
* (format t "Hello, Lisp World!~%")
Hello, Lisp World!
NIL

Create a file named hello.lisp:

;;; hello.lisp
(defun hello ()
(format t "Hello from a file!~%"))
(format t "File loaded.~%")

Now, load this file into your running REPL:

* (load "hello.lisp")
File loaded.
T
* (hello)
Hello from a file!
NIL
* ; To quit the REPL, type (quit) or press Ctrl+D
* (quit)

Quicklisp is the essential library manager for Common Lisp. It lets you download, install, and manage thousands of open-source libraries with a single command. Follow the installation instructions on the official Quicklisp website. Once installed, you can load a library like this:

* (ql:quickload :drakma) ; Loads the Drakma HTTP client library