Archive for December, 2011

An Intro to Lisp Editors and IDEs

Thursday, December 22nd, 2011

(or Lisp IDEs where for art thou revisited)

A while ago I wrote a post berating the lack of full-blown IDEs available for the various Lisp languages (cue the sound of Emacs fanboys sharpening their knives in the background ;) ). To some degree I regret that post, as although its popularity proved it hit something of nerve, it was basically a whine that lacked helpful or insightful comment.

Whilst my views haven’t substantially changed, in this post I thought I’d try to put things right by compiling some advice to people who want to edit Lisp for the first time.

In the beginning was the REPL

To begin with forget about the editor or IDE. Just use whatever simple text editor you are used to in conjunction with the REPL, whether this is Notepad, gedit, nano or Vim (or, yes, Emacs). Don’t even worry about syntax highlighting etc if you are just trying out a few simple examples. Most Lisps come with a pretty decent REPL, especially CLISP and to a lesser degree SBCL and Clojure1.

Get used to typing in simple functions and testing things out directly in the REPL. Once you start wanting to save your work, just learn your Lisp’s command to load files (e.g. (load 'filename.lsp') in SBCL or (load-file 'filename.clj') in Clojure) and use this to in-directly interface with your text editor. This should actually provide you with quite a friendly environment, where it is quick and easy to build your code up and try out changes in the REPL.

Next Steps

The advantages a more integrated Lisp editor will bring you are things like syntax highlighting, code formatting and an integrated REPL with the ability to evaluate single expressions at a time rather than whole files. More advanced environments (notably Emacs) will include debuggers and other tools.

Unfortunately, there a few options to pick from here and they are not all equal. If you already know (and like?) Emacs, your decision is easy and you just need to look at some documentation on getting slime and paredit set-up. Emacs is probably the most common and perhaps the most powerful setup. The disadvantage is needing to learn Emacs, although there are some packages designed to make this a little easier, such as lispbox and aquamacs (Mac only).

If you know Vi or Vim, the slimv plug-in has progressed very nicely and provides most of the functionality of its Emacs cousin, although I find the modal editing of Vi can make using the REPL a little awkward.

If you’re used to IDEs such as Visual Studio or Eclipse and would rather not leave their cosy warmth, you are in for a rougher ride. The best I have found so far is counterclockwise, a Clojure plug-in for Eclipse. There are Eclipse plug-ins for other Lisps, but all the ones I found were abandoned and/or buggy (this has possibly since changed but my experience was bad enough that I don’t want to revisit it). There is also LispWorks, which looks good, but note that there are significant restrictions on the free (as in beer) version (mainly that you can only use for up to 5 hours a day per session). In most cases it seems you are best advised to bite the bullet and learn Emacs.


A final honourable mention needs to go to Racket, which includes its own IDE, DrRacket. This seems to be a really nice environment for learning in. If you just want to play around with functional programming, this might be exactly what you are looking for — it comes with a great tutorial which gets the user playing with graphics primitives directly in the REPL (circle, rectangle etc). However, if you want to use a different type of Lisp, you will need to consider the above choices.

I believe that this covers the main choices, although there were some other suggestions in the comments to the previous blog. Again, the main take-away should be not to worry about IDEs at first. Just get started with the REPL and a text editor and put off the IDE question till later.

  1. If you’re getting started with Clojure, I recommend using leiningen to install Clojure and launch the REPL, but at least make sure you install JLine or rlwrap to improve the basic REPL. There also seems to be some work on a more advanced Clojure REPL called nREPL. []