3 minute read

Here you can find short notes about setting up a fresh Common Lisp environment and how to create your first project.

Environment Setup

Start by installing these applications (or some equivalent):

  • SBCL: one of the most popular CL compilers. It can be installed by the package manager (like apt-get install sbcl).

  • Emacs/Spacemacs: a decent editor. For Vim users like me, I suggest Spacemacs (check my configuration).
    • Slimv is also a very good alternative for Vim users.
  • Quicklisp: the most popular library manager.
curl -o /tmp/ql.lisp http://beta.quicklisp.org/quicklisp.lisp
## Installs quicklisp at ~/.quicklisp.
sbcl --no-sysinit --no-userinit --load /tmp/ql.lisp \
     --eval '(quicklisp-quickstart:install :path ".quicklisp")' \
     --quit
;; Call "sbcl" on terminal.
* (load "~/.quicklisp/setup.lisp")
;; Load quicklisp automatically for every CL session.
* (ql:add-to-init-file)
  • ASDF: “a system definition facility for Common Lisp programs and libraries”. This will be installed automatically by Quicklisp just by following the other steps in the next sections. However, we need to set it up.
;; Content of the file ~/.config/common-lisp/source-registry.conf
(:source-registry
  ;; Replace "code" by your preferred directory.
  (:tree (:home "code"))
  :inherit-configuration)

New Project

Taken from Baggers:

  1. In a terminal, call sbcl inside the parent directory of your new project
  2. Load quickproject: (ql:quickload :quickproject)
  3. Create the project structure: (quickproject:make-project "some-project-name")
  4. Check the new directory some-project-name

The project structure (or the “system”) is defined in the file some-project-name.asd. Follow this reference to understand better the file.

Cloning a project template is another quick approach.

Version Management

As far as I know, Quicklisp doesn’t understand the dependencies’ versions defined in the asd file. However, I like to put their versions down anyway, like this:

  :depends-on ((:version "drakma" "2.0.4")
               (:version "jonathan" "0.1")
               (:version "cl-arrows" "0.0.1")
               (:version "ironclad" "0.34"))

Conclusion

After some years coding in Clojure, I got really used to the facilities provided by Leiningen and Maven; for CL, I was surprised that I couldn’t easily find a way to start some serious, well organized project. In this post I try to summarize all the information I gathered from many different sources just to start a new simple project.

If you have some better suggestion, please send it to me by email. I would be really happy to learn something more.

References