Common Lisp

Common Lisp is the modern, multi-paradigm, high-performance, compiled, ANSI-standardized, most prominent (along with Scheme) descendant of the long-running family of Lisp programming languages.

Resources

Implementations

Common lisp is just a standard, you will need to choose the implementation(s) according to your needs. Below is a simple table that gives you a brief idea of the implementations available.

Implementation Installation Target(s) License
SBCL apt,pacman ,nix, guix Machine Code Public Domain
ABCL apt,pacman ,nix, guix JVM byte code GNU GPL3
Clozure (CCL)   native code LLGPL
ECL apt, nix, guix C GNU LGPL2.1
CLASP   LLVM LGPL2.1
LispWorks     Proprietary
Allegro     Proprietary
CLISP      
SICL      

Steel Bank Common Lisp (SBCL)

The most popular FOSS implementation with the highest comptability.

Armed Bear Common Lisp (ABCL)

Clozure CL (CCL)

Installation

Roswell

Roswell allows you to install multiple implementations and change smoothly between them. It also already includes quicklisp for you so you don't have to manually install it (there's an option to disable quicklisp if you want).

Install Roswell

Roswell is available in many package managers on many Linux Distributions.

Ubuntu/Debian

You will need to install roswell manually:

curl -L https://github.com/roswell/roswell/releases/download/v23.10.14.114/roswell_23.10.14.114-1_amd64.deb --output roswell.deb

sudo dpkg -i roswell.deb
Arch
pacman -Syu roswell
Void
sudo xbps-install -S roswell
Gentoo
emerge --ask dev-lisp/roswell
FreeBSD

Roswell is available in the FreeBSD ports tree. To install it system-wide

cd /usr/ports/devel/roswell 
sudo make install

To avoid system-wide installation, simply define a PREFIX (must be an absolute path)

cd /usr/ports/devel/roswell
sudo make PREFIX=/usr/home/<username>/.local install 
Nix

The roswell package is availabe in nixpkgs and you can refer to the instructions below for more detailed instructions on how to setup lisp with Nix.

Guix

The roswell package is availabe in Guix and you can refer to the instructions below for more detailed instructions on how to setup lisp for Guix.

Install implementation(s)

To install an implementation:

ros install sbcl-bin
ros install ccl-bin # or any other implementation

Then to make an implementation the default for roswell:

ros use sbcl

You can always manually set the implementation you want to use without changing the default implementation:

ros run -L ccl-bin

Debian/Ubuntu

The implementations sbcl, abcl, ecl are available with the apt package manager

apt-get install <implementations>

Arch

pacman -Sy sbcl

Nix

The following implementations are availabe as nix packages:

  • sbcl
  • abcl
  • ecl
  • ccl
  • clasp-common-lisp
  • gcl (GNU Common Lisp)
  • clisp
  • roswell
Nix OS

You can add the implementation packge to your environment.systemPacakges to install it system wide.

For dealing with external libraries. You shoud include the .dev suffix to the library name to make sure the library path is added to the search path. for example for openssl you should add the package openssl.dev to your system packages

Home Manager

For dealing with external libraries. you need to add the absolute path of the required libraries to the LD_LIBRARY_PATH environment variable. While you can do that on your home environent level, it is highly not recommended. A work around is to wrap your implementation package with a simple shell script to make sure the installed libraries are added to LD_LIBRARY_PATH for your implementation. Here's an example for sbcl but you can do the same for the other implementations or for roswell.


Nix Shell

We included a flake.nix file that you can use by running the command nix develop to enter a shell were you can get started right away with all the available implementations.

The LD_LIBRARY_PATH should be set to include the absolute path for the libraries needed. To do so we use the helper functions makeLibraryPath to build the path for us and set it in our development shell.

Guix

The following implementations are availabe as guix packages:

  • sbcl
  • abcl
  • ecl
  • ccl
  • gcl
  • clasp-cl
  • clisp
  • roswell
Guix OS
Guix Home
Guix Shell

We included a manifest.scm file that you can use by running the command guix shell -m manifest.scm to enter a shell were you can get started with all the available implementations and tools mentioned in this guide.

Init file

REPL

Normally, running the command for you implementation will get you into the REPL. If you are using Roswell, running the command ros run will get you into the REPL for the default implementation or you can specify a specific implementation by running the command ros run -L <your-implementation>

However, Most REPLs don't allow you to go back in history. To that you will need to use rlwrap, a command line utility that help you navigate the history of you REPL commands. To use it just prefix your implementation command by rlwrap for example rlwrap sbcl. This will allow you to navigate the history of your REPL commands using the up and down arrow keys.

Editor Setup

Emacs

The main packages that allow interaction with the REPL are slime and sly. SLY is a fork or slime and adds more features to it. You can use the provided init.el by running the command emacs -Q -l init.el to run emacs with the minimal configuration to get you started. Make sure to change the inferior-lisp-program in before running the command to run with your implemenation of choice. You can also customize the variable lisp-repl to shoose either sly or slime. Alternatively, you can follow the guides below to learn how to add these packages to you emacs configuration.

Remember that Sly and Slime are conflicting. If you decide to install one remember to uninstall the other.

SLIME

Add the following to your emacs configuration init file.

(use-package slime
  :ensure t)

Sly

Add the following to your emacs configuration init file.

(use-package sly
  :ensure t)

Vim and NeoVim

slimv

vlime

Package, System and Dependencies

System Definition

ASDF

ASDF, or Another System Definition Facility, is a build system: a tool for specifying how systems of Common Lisp software are made up of components (sub-systems and files) The def system form Example of hello-lisp.asd

;; Usual Lisp comments are allowed here
(defsystem "hello-lisp"
  :description "hello-lisp: a sample Lisp system."
  :version "0.0.1"
  :author "Author Name <username@example.com>"
  :licence "Public Domain"
  :depends-on ("optima.ppcre" "command-line-arguments")
  :components ((:file "packages")
               (:file "macros" :depends-on ("packages"))
               (:file "hello" :depends-on ("macros"))))

You can then load this system in the REPL as follows:

(asdf:load-system :hello)

Dependencies Management

QuikLisp

curl -O https://beta.quicklisp.org/quicklisp.lisp
# replace sbcl with your implementation
sbcl --load quicklisp.lisp

If you are using roswell, quicklisp comes already included you don't need to install it manually.

Qlot

Roswell

Roswell is a Common Lisp implementation installer/manager, launcher. You can use it to install multiple implementations, run REPL and install binaries. It already comes with quicklisp pre-installed.

Ecosystem

Extensions libraries

Web Development

GUI

Notable Projects