Lisp Enlightenment and Emacs Frustration

July 06, 2007 By: erik Category: Complaining, Geeky, Programming 14,646 views

Rate this post:
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.50 out of 5)

I have recently had my interest piqued about Lisp. I learned a little Lisp back in college for some Artificial Intelligence classes that I took. It struck me as a rather awkward language.

Several months ago, I found this article by Paul Graham about how he, in 1995, way before the dot-com boom, started a company, called Viaweb, to make customizable online stores, exactly five years before I, too, started a company to make customizable online stores. The only difference is that he sold his to Yahoo! for millions of dollars. In the article, he claims that the key factor that let his company beat out the competition at every turn was that they wrote their software in Lisp. He quotes Eric Raymond:

Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.

In my investigation, I’ve found that this moment of enlightenment is mentioned by many other Lisp users (aka. Lispers). As a non-Lisper, I was reminded of the feeling I had when those Magic Eye stereograms became popular. I felt like everyone around me was staring at something that appeared uninteresting and saying, “Whoa! Cooooool!!!” I just didn’t get it.

Then, a few weeks ago, I found an article called The Nature of Lisp, by Slava Akhmechet. His stated goal of the article was to look back at his own path to Lisp enlightenment, and then reach out to the unenlightened and describe why Lisp is so cool in terms that non-Lispers understand, namely XML and Ant. Compressing the article into one sentence, the main point that non-Lispers don’t get is that Lisp blurs the line between data and code much like Ant is code written in XML, a format used mostly for data, and this lets you manipulate your Lisp code with Lisp itself. See how hard that is to understand? There’s a reason Slava’s article is so long.

I was just beginning to see the light. I had seen through the keyhole to a beautiful world out there, if I could just pry the door open a bit more… The next step was reading Practical Common Lisp, a book by Peter Seibel, that he has released free on the web. I am the exact audience that the book was written for, a pretty good programmer, well versed in one language, and interested in understanding why Lisp is so great. In his introduction, he states,

If you’re a hard-nosed pragmatist who wants to know what advantages Common Lisp has over languages such as Perl, Python, Java, C, or C#, this book should give you some ideas. Or maybe you don’t even care about using Lisp–maybe you’re already sure Lisp isn’t really any better than other languages you know but are annoyed by some Lisper telling you that’s because you just don’t “get it.” If so, this book will give you a straight-to-the-point introduction to Common Lisp. If, after reading this book, you still think Common Lisp is no better than your current favorite languages, you’ll be in an excellent position to explain exactly why.

In the past few weeks, I’ve more or less read Practical Common Lisp from cover to cover. I skipped over some of the stuff at the end about parsing MP3 files. And the final conclusion is that: Lisp is far better than any programming language I’ve ever learned, including Java, which is more or less my “mother tongue” these days. Even if you tie macros (Lisp’s true source of power) behind its back, its object inheritance, error handling, and variable scoping are far more robust and flexible than Java’s.

My programming language path went from BASIC to C++ to Java, with slight dabbling in C and Pascal along the way. As such, I thought that concepts like “everything is an object“, “every variable is really pointer to an object”, garbage collection, and running on a virtual machine were all brand new concepts in Java. And just recently I’ve been amazed at the power of concepts like closures and first-class functions in Javascript. And now I learn that Lisp was doing all this and more a decade before I was born?? Mind. Blown.

So here I am. I’ve seen the light, and it’s absolutely beautiful. I’ve pried open the door and am gazing, slack-jawed, at the blissful sunny meadows of efficient, elegant Lisp programming. As I’m preparing to leave behind my dank dark prison cell of Java, vowing never to return, a little voice in the back of my head says what I was trying all along not to think about.

If it’s so nice and perfect out there, why is there no one out there? You think you’re so smart that, in only two months, you’ve figured something out that none of the other poor schmucks in the neighboring cells haven’t?

“Shut up,” I murmured, and sprinted for the open door. And that was when I slammed, face first, into the invisible pane of glass called Emacs.

At work, I spend almost all of my time using an application called IntelliJ IDEA, an integrated development environment (IDE) for Java. IntelliJ makes Java programming as easy as it can possibly be. It more or less compiles your code as you type it, points out most bugs as they occur, intelligently suggests code completion to finish your words for you. I generates all the annoying repetitive code, like getters and setters and equals() methods for you. Without it, Java would be much more laborious to program in (but still not as bad as other languages in the C family tree). Java has many other IDE alternatives, but none truly stack up to IntelliJ.

A couple years ago, I began using a plugin for IntelliJ, called IdeaVIM, that allows me to use Vim key mappings in IntelliJ. Vim is a successor to Vi, which is an ancient UNIX text editor. The main value that it provides is allowing you to move your cursor around a text file without moving your fingers from the home row, thus greatly reducing RSI.

Lisp, on the other hand, has only one IDE. That IDE consists of Emacs, another ancient, extensible text editor, and SLIME. There are some commercial IDEs, but they all use Emacs key mappings and don’t improve the interface that much, so what’s the point? This 55 minute video (mov) (torrent) demonstration of Emacs and SLIME, by Marco Baringer (one of Lisp’s leading developers, it seems), is pretty impressive and demonstrates an efficiency of development comparable to that of IntelliJ. You can even do some things that IntelliJ (and Java) can’t do, such as compile code directly into a running remote server.

Vi and Emacs are long time rivals, and the internet is full of bitter arguments about which is superior. The fact is that they both provide ways of moving quickly around a text file and modifying entire blocks of text. And, most importantly, both of them have incredibly steep learning curves.

I just spent all this brain energy comprehending the infinite power of Lisp, and now I’m stuck at the bottom of a learning cliff that prevents me from going any further before learning an awkward set of key combinations to edit a text file. Coming from a Vim background, what I can’t stand about Emacs is that you have to hold down the Ctrl or Alt key practically the entire time you’re using it. This is enough to make a Vim user scream! Emacs seems like a sure way to RSI. This is a huge stumbling block for me at the moment, and it’s particularly frustrating because of my desire to flex my newly formed Lisp muscles.

It seems 100% crystal clear that if you want to be a Lisp developer, you have to use Emacs. This is just a fact that I’m going to have to accept and either give up or learn Emacs. I suspect that this is the major reason that Lisp isn’t more popular. There are other problems like how the lack of rigid structure makes managing large teams of programmers difficult, but I bet the main glass wall keeping people in their cells is the difficulty of learning a new and different language and a new and different text editor.

Hopefully it’s just a matter of time. I clearly recall a time when I thought, “Vi is so hard to use! Why would anyone want to learn such a difficult editor?” And now I can’t imagine life without it. I’ve mainly written this post as a diary entry, both to organize my thoughts on the matter, and hopefully to have something to look back down on after scaling the Emacs learning cliff.

  • the daniel

    You mentioned Graham in your post – seems vi worked for him ( ) so you may not need to feel trapped in emacs-land after all. If all else fails there’s always M-x viper-mode 🙂

  • I’ve tried viper-mode. While a nice attempt, it doesn’t really work. Some buffers use it and some don’t. Particularly all the helpful buffers that SLIME provides (like the debugger and code completion) and the REPL. So you have to become an expert at the C-b, C-f, C-n, C-p navigation anyway…so what’s the point?

    Thanks for pointing me to that page, though. I feel better already. 🙂 My current, minimal, Lisping has been done in Vim with a CLisp REPL open, arrowing up to (load “myfile.lisp”) every time I make a change. I wonder how Paul Graham really does it…

    • Elena

      > I\’ve tried viper-mode. While a nice attempt, it doesn\’t really work. Some buffers use it and some don\’t. Particularly all the helpful buffers that SLIME provides (like the debugger and code completion) and the REPL. So you have to become an expert at the C-b, C-f, C-n, C-p navigation anyway…so what\’s the point?

      Cheers ^_^

  • santhalus

    Did you check the vimpulse mode? Maybe it will suit better your needs.
    There are also Easymacs and EMacro projects, which modify Emacs’ default settings to more modern standards.

    You don’t need to learn nor use Emacs’ default key combinations in order to use Emacs effectively. This seems to be a common myth which discourages many potential users. I personally hate the way that Emacs works out of the box and this put me off at the beginning, too. However, after looking at other people’ config files and a little tweaking and I was able to make it work exactly the way I wanted.

    Remember that Emacs is also mainly written in Lisp (an early dialect but Lisp nonetheless) so tweaking and learning it will boost your Common Lisp practice.

  • santhalus: Thanks for the links. I’ll check ’em out. I understand that Emacs is completely customizable. Paul Steuber’s OS X setup is pretty nice.

    I’m reminded of how scary and daunting losing my Linux virginity was. It’s possible to be too configurable.


    Thanks to a comment on reddit, I’ve downloaded Eclipse, the Cusp plugin, and the Vi plugin, and I’m very happy with what I’ve seen so far.

    I rather dislike Eclipse for Java development. I’ve tried downloading it several times over the years and found it inferior to IntelliJ every time. But it looks like it might be just what I need to spread my Lisp wings.

    Thanks to all those who commented. The comment in the form of an Emacs extension to print out “Fear not, dear Erik, for this is the last cliff you’ll ever have to scale.” was quite clever. Unhelpful, but clever.

  • ardaliev

    Cusp, a Lisp plugin for Eclipse

  • Emmett Witherspoon

    No, you don’t need emacs or slime to be a lisp developer. Both are worthless. Don’t get too mesmerized by the slime video. There’s absolutely nothing noteworthy about emacs+slime that I can’t do with a couple of gnome terminals, some gnome keybindings, and vim. Vim is actually better for editing lisp expressions than any mode of emacs.

    Use slime+emacs long enough and you’ll be gradually aggravated to the point of insanity by annoying default behaviors. Helpful morons will tell you to waste your time slogging through mailing lists and elisp garbage if you want to change these. As if you don’t have better things to do with your time. Don’t bother. Emacs+slime is a time-wasting brain-sucking plaything.

  • Stuart Overton

    I wouldn’t worry about the difficulty of learning Emacs. I started with Emacs, then moved to vi, then back and forth for a while until I finally settled on the perfect editor: both of them. If you switch back and forth, the default key bindings just stick with you after a while. So, I use Emacs for long programming sessions in various languages, but when I’m at the command line, I tend to use vi, for editing rc files, shell scripts, subversion logs, etc.. It loads faster than Emacs and is also extremely powerful. I even took the time to learn ed, just in case I ever need it, say, if I accidentally delete Emacs or vi, which is unlikely to happen as Emacs and vi are editors you could only take from me by prying them from my cold dead hands.
    I say learn ’em both. It’s like being multilingual. It can’t hurt ya’!

  • Udyant Wig

    Lisp is well (for a vague and weird analogy) like Cthulhu (of H P Lovecraft fame). It has capabilities and concepts so different, so powerful, so … *beyond*, that makes it hard to grok it at all at first.

    In the current scenario, Lispers are not in demand because of 2 reasons, I think:
    1) Only a Common Lisp specification is official,
    there is no authoritative implementation.
    2) No standard libraries for many modern problem
    and application domains.

    In short, although you can and will gain a “profound enllightenment”, Lisp has not evolved.

  • PFar

    Excellent blog post. Take a look at Clojure ( A Lisp dialect written for the JVM. An awesome language.

    It nicely solves #2 ) above quite well : “No standard libraries for many modern problem and application domains.” Clojure has first class Java Interop.

    As for IDEs, there are plugings for all the majors (e.g. Netbeans, Eclipse, etc.).

  • I’ve been climbing the Lisp cliff, and I have had the same problems than you, emacs. I tried. I really tried. Being a hardcore vim user, using emacs is particularly painful, and I finally came back to vim.
    I now use only vim to develop in lisp, and if I don’t have all Slime’s nifty features, I compensate with vim’s.

    Since, I read Doug Hoyte’s Let Over Lamba, and discovered I wasn’t the only one to program in lisp with vim, so I stopped to worry about it.

    Enjoy lisp AND vim 🙂

  • Isaiah

    I hate emacs too. I’ve been trying to get lisp working with vi, but can’t find syntax files. I think I’ll make my own IDE as a project to learn more of lisp. I want to make something like netbeans and slime mixed together.
    Will be a great learning experience. And hopefully better then scite.

  • Bjoern

    Some tips for choosing the right keyboard for emacs.

    Even with plugins like LIMP or SLIMV, vim sadly cannot match emacs when it comes to Lisp. I wish it was different.

    But, emacs isn’t that bad, it’s only real problem being the Control-Meta-Shift hell. And that can hopefully be fixed with the right keyboard and some remappings.

  • Alex

    Have you thought about remapping Caps-Lock with Control? You can stay on the home row with that. You can also use Esc instead of Alt for Meta, if that’s more convenient. Of course you can also use viper-mode or just use vim for Lisp. Those work just as well.

  • Arjun Mukherjee

    Vim rules for Lisp too. I am also a Lisp hacker but I use a combination of:
    gVim (on Ubuntu)
    My own simple shortcuts in Vim
    Small Python plugin for Vim

    You will not miss slime, etc.

    Note: I have hard coded certain things and it can be made generic. Just hacked it up when reading Land of Lisp.

    Here you go:

    * Install screen

    * Open a terminal
    screen -S session01

    * Press C-a
    * Press Shift-A

    * Give the window a name – window01 (Note you can name anything you want – just change the scripts. It is all hardcoded right now. But super comfortable to use)

    * Now open your vimrc

    ; Basically in visual select mode – ;e – sends your Lisp forms to SBCL or whatever – and bang code gets executed – Stay put in Vim !
    vmap ;e “ay:call system(“screen -S session01 -p window01 -X stuff \”” . escape(@a, ‘`”‘) . “\”\r”)

    ; In normal mode – just press – f – and the current line is sent
    nmap f V;e

    ; Press – ;g – and the output of the last command is right below the line you type – cut and put it inside your notes 🙂
    nmap ;g :py screen_dump()

    * Here is the Python plugin

    python < 0:
    if l.startswith(‘*’):
    count += 1
    if count == 2:
    lastcmd = lastcmd[1:]
    lineno, col = vim.current.window.cursor # mark the next line – since lineno is 1 based
    # Basically adds n blank lines and these are then filled up
    vim.command(“normal %do” % len(lastcmd))
    endlineno = lineno + len(lastcmd)
    vim.current.buffer[lineno:endlineno] = lastcmd

    * Sorry once again for the hardcoding – it was all hacked up in couple of minutes

  • Yuryshev

    In fact I can’t understand what is bad in emacs.

    I’m a novice to emacs, I’ve installed it 2 weeks before today.

    I have experience/use regulary: vim, visual studio, Delphi/CBuilder IDE, PyScripter, notepad++.

    What I found extremely pleasant in emacs: It does not have a learning curve at all.

    Yes. In fact all I need to figure was Alt-X. And then cua-mode.

    It’s fun to use, I suppose it will be my general text editor in future.

  • If it’s only RSI worries that is keeping you back from emacs than I’d highly recommend using a foot pedal for the alt and meta keys.

  • Samantha Atkins

    Your next enlightenment is that lisp is built in to emacs. At least a less powerful than CL lisp is. Which means that your entire environment is effectively one language. Emacs is far far more programmable than Vim will ever be. It is worth learning.