An Intro to Lisp Editors and IDEs

(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.

Racket

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. []

12 Responses to “An Intro to Lisp Editors and IDEs”

  1. Jon Says:

    The Lispworks Personal Edition is actually restricted to 5 hrs per session not by day. Once it has closed it can be immediately restarted again for another 5 hours. Personally I find the heap size restriction and not being able to deliver applications more restrictive.

    Regards, Jon

  2. Adrian Mouat Says:

    @Jon, thanks for the clarification. So every 5 hours you have to close it and open it? Seems a little odd. I have to confess I didn’t bother trying it out after reading the restrictions, but it looks like a good IDE.

  3. dave Says:

    having tried several approaches (cusp with eclipse, the LispWorks ide, emacs), the sole contender is —— Emacs. unfortunately, it takes weeks to get the whole thing running.

    but there are so many quirks that it hurts you a lot. i still have not been able to figure out
    a) how to set it up on kubuntu (seriously, it just does not work. i don’t know what to do.)
    b) how to hook up lispworks (i even have the professional edition. please no links to bill clementson.)

    overall, being a less than average programmer, i have gotten to hate Lisp. it might be awesome stuff for the seasoned computer scientist, but for anyone else: STAY AWAY FROM THIS TRAGEDY, or get ready for a rough ride. if you ever thought c++ was hard, i have news for you.

  4. Sebas Says:

    @dave: emacs is really easy to setup, even on Kubuntu (I use Ubuntu and it’s just apt-get install emacs emacs-goodies-el). The next thing is to get a prebuilt .emacs file, drop it on your home folder and customize it. Then download and install quicklisp, and learn how to use it. It does get easy after a day or two.

  5. foobar Says:

    There are commercial Lisp IDEs: LispWorks and Allegro CL are the best among those. That those cost money, does not mean that they don’t exist. Both have editions which cost nothing, come with some limitations (like LispWorks whose Personal edition does cost nothing, but quits every five hours, so you have to restart it). Also not that these editions are not ‘free’ in the sense of ‘free software’.

    GNU Emacs + SLIME is a popular development environment for Common Lisp. It does not only provide an editor mode, but also a REPL, a debugger and other tools.

    Another option is Clozure CL, which is an excellent Common Lisp implementation, free and no-cost and comes with an IDE on Mac OS X. This IDE has a rough port to Windows. On Mac OS X, Clozure Common Lisp now can also simply be downloaded via Apple Macintosh App Store – and it is then only a click away in the ‘programs’ folder. This makes installation easy.

  6. dave Says:

    @Sebas:

    > The next thing is to get a prebuilt .emacs file, drop it on your home folder and customize it.

    I meanwhile can even write a .emacs myself, I (think I ) know what goes where, I looked up all the stuff in the Slime manual. Still, just not working. Tried it with CCL and SBCL.

  7. Adrian Mouat Says:

    @Jon & foobar; I’ve corrected the information on LispWorks.

    @foobar; you are right that I shouldn’t dismiss IDEs as non-existent just because you have to pay for them. However, the majority of people starting out with Lisp will be unwilling to do so and therefore I feel they are outwith the scope of this article. I am aware of what Emacs provides, apologies that I didn’t make this clear in the article – I’ll look at updating it later.

    @dave; I feel your pain, but so many people use Emacs on a multitude of linux distros that your problem must be solvable. Perhaps try asking on StackOverflow or something similar?

    Adrian.

  8. Adrian Mouat Says:

    @foobar; I’ve added some info on other features.

  9. Anders Says:

    I run Intellj Comunity version == free
    and Clojure plugin works perfekt and cost is = None

  10. michael Says:

    “The disadvantage is needing to learn Emacs”

    I don’t think I understand the mindset that dreads learning something new, especially something as rich, powerful, and widely supported as Emacs. If I didn’t want to learn something new, I wouldn’t be using Lisp in the first place. This is like a car review that says “The new BMW is a great car, but unfortunately you have to learn how to drive”. Well, yeah!

    Sebas said: “emacs is really easy to setup, even on Kubuntu (I use Ubuntu and it’s just apt-get install emacs emacs-goodies-el). The next thing is to get a prebuilt .emacs file, drop it on your home folder and customize it. Then download and install quicklisp, and learn how to use it. It does get easy after a day or two.”

    I’m an Emacs user but I never would have guessed “emacs-goodies-el”. Where do I get this “prebuilt .emacs”, and what’s it for? How am I supposed to “customize it”? Seriously, that’s what passes for “really easy” these days?

    I think we would have more luck if we said “There is a lot to learn, but it is fun, and can make you more productive at almost everything you do on a computer”, rather than trying to tell people it’s “really easy” and having them get frustrated when they learn that this isn’t true at all. The comparison that people are using these days isn’t punchcards any more: it’s iPhones.

  11. shubham Says:

    I am trying LispWorks PE & Lisp seems quite interesting as of now.

  12. Julian Says:

    For Clojure, I’d recommend Light Table as a first step. It’s “Instarepl” is a wonderful tool for learning and playing around. Once the language feels more comfortable, I’d also recommend the Live pack for emacs that comes with paredit and cider (the new nrepl), ready to go.

    As someone who learnt Clojure and Emacs at the same time (with minimal prior lisp), my recommendation is to stagger that process. While the return is great, they both demand an fair effort to wrap your brain around, and doing both together was a bit unpleasant. Either use emacs for a with your current language, or use a comfortable editor. Just for a little while.

Leave a Reply