Running Lisp on Mason
Lisp runs fine on mason.gmu.edu (type lisp). But only use Lisp on Mason to verify your code, not for development. Instead, do development on your own machine -- it's much less painful. However, in Prof. Luke's classes, your Lisp homework and projects must compile and run properly on Mason for them to count. So be sure it's working on Mason.
If you're familiar with Emacs, you may wish to run lisp under emacs on mason. You probably will want to install slime as well. See below for more information.
Getting a Lisp system at Home
On the Command LineThe basic, if primitive, way to get Lisp running is to install a command-line Lisp system. This works especially well if you have a UNIX system (OS X or Linux). Command-line Lisps include:
- SBCL is a recent revision of CMUCL with new modifications and additions. I recommend SBCL as the best command-line Lisp. However, SBCL is very verbose and warning-filled though, which can get quite annoying. On the Mac, if you prefer a quieter, more forgiving, and decently fast Lisp, try CCL or MCL.
- CLISP is a good Common Lisp, and is highly portable to nearly every environment out there. However, the reason it is portable is that it compiles to a bytecode interpreter rather than to machine code, and so it's pretty slow.
- MCL is a freeware command-line-only version of Macintosh Common Lisp, which runs under MacOS X nicely. It is much faster than CLISP on the Mac, but its debugging facilities are primitive.
- CCL, or Clozure CL, was a fork of MCL way back when but now is a high-performance Lisp implementation in its own right, and runs on a lot of different platforms. If you're getting annoyed at SBCL's verbosity, try CCL.
- CMUCL is a first-rate Common Lisp, but it is not available on all platforms. CMUCL is the system from which SBCL sprang.
- If you're interested in playing around with it, ABCL is a Common Lisp implementation which runs on the Java VM. Note that it's not particularly fast (yet).
Lisp IDEsLisp is an interactive programming language and IDEs were invented originally for Lisp. Use an IDE designed for Lisp -- it will make your coding far more productive. There are several approaches to doing this:
- Use a Lisp system with a built-in GUI. The best two choices here are:
- Franz Allegro Common Lisp for Windows, Linux, and FreeBSD.
- Xanalys LispWorks Personal Addition for Linux, MacOS X, and Windows. This package has the added advantage of being the same exact kind of common lisp as the installation on mason.gmu.edu.
Other examples include Corman Lisp on Windows.
- Use a command-line Lisp attached to Eclipse. To do this, first install SBCL or Clisp. Then install a plugin. Two I know of (but have no experience with) are:
- Use a command-line Lisp attached to GUI Emacs+slime. This is the approach that I take.
- A graphical version of Emacs is available on most systems, particularly Linux boxen which often have it built-in.
- On OS X, try Aquamacs, a good cocoa Emacs.
- You should augment your Emacs system by installing slime a set of Emacs extensions which dramatically enhance its ability to act as an IDE for Lisp.
One gotcha that befalls students is that Emacs is also written in Lisp -- just not Common Lisp. Emacs is written in its own variant of lisp called, not surprisingly, Emacs Lisp. But you're not using Emacs Lisp. Instead, you're using Emacs to run and control another Lisp system (SBCL, etc.) However, it's easy to mix up running code in Emacs Lisp with running code in the underlying Common Lisp system. So just be aware of this fact in case you start getting lost.
Emacs+SLIME+Lisp is so common an approach that there are several all-in-one installation bundles available:
- You might try the LispBox page, which has installers for Franz Allegro, OpenMCL, SBCL, and CLISP, on Windows, Linux, and OS X. I've not tried it myself, but you might have luck there. And the guy knows what he's talking about. Apparently he's not going to be maintaining it much anymore however.
- Another nice all-in-one bundle for OS X is ReadyLisp, which ties together Aquamacs Emacs, SLIME, and SBCL.
- Use a command-line lisp plugged into the terminal version of Emacs+slime. This is rather more painful, though less painful than logging into mason! The procedure here is essentially identical to the GUI Emacs above.
- Use SBCL attached to vim See the limp project.
Another new project which tries to do some of SLIME inside of vim: slimv.
Not Common Lisp
You should be aware that there are two other variants of Lisp out there which are NOT Common Lisp. Those variants are Scheme and Emacs Lisp. Do not use either one. Scheme is a really nice language, but it's not what we'll be using. BTW, if you want to try out Scheme, PLT Scheme is definitely the way to go. If you'd like to instead edit Scheme with Emacs, check out quack.
There are some new Lisp-related languages lately. Qi tries to move Lisp towards strong typing languages like Haskell or Ocaml. Clojure is a Lisp of sorts which is designed to directly target the Java Virtual Machine. And Arc is Paul Graham's exploratory revision of Lisp for rapid coding.
My Tutorials and Assorted Lisp StuffLisp is a daunting language. To help you get up to speed quickly, I have put together three Lisp tutorials that cover concepts of the language which are similar to languages you've already seen. This should enable you to do basic programming in Lisp. I give short shrift to features special to Lisp. Afterwards you should have enough basics to tackle the "special to Lisp" features (macros, CLOS, etc.) in a textbook at your own leisure.
- Lisp Tutorial 1: QuickStart. GMU Students: pay particularly close attention to the "Lisp Style" section.
- Lisp Tutorial 2
- Lisp tutorial 3
- A cheat sheet for using various data structures in Lisp.
- A very short tutorial on Cons Cells
- My doseq macros, simple examples of useful Lisp macros.
- My snarf object-oriented language. Much smaller and simpler than CLOS. An example of how you can bend Lisp to your will (in this case: I've modified Lisp to support an OO language with a fe macros and functions). This is often how Lisp is used in big projects -- programmers twist Lisp into the language they'd most like for their project, then write in that language!
Other People's Lisp Tutorials and Information
- One of the best books out there is now available entirely online. It's a lisp tutorial called Practical Common Lisp, by Peter Seibel. It's got a lot of examples that you may find helpful.
- Another good online Lisp tutorial called the Lisp Primer. It's very good.
- CMU's David Touretzky put his 1990 book, Common Lisp: A Gentle Introduction to Symbolic Computation, online as a PDF file. Still a very good text.
- If you're looking for all sorts of information about Common Lisp (books, online resources, software, whatever) try the Common Lisp Introduction.
- Common Lisp is very big -- if you need a complete reference to Common Lisp to find just that function you're looking for, try Harlequin's Common Lisp HyperSpec.
- Paul Graham's book On Lisp, a fine book on advanced Lisp, is out of print. So he has graciously made it available online! Including source code.
- Peter Norvig wrote a book called Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp, which goes through many large AI projects and implements them in their entirety in Lisp. Norvig has provided the source code on his web page. Also, the web page for Russel and (again) Norvig's Artificial Intelligence: A Modern Approach has a ton of code in Lisp, among other languages. Did I mention that Norvig's now Director of Research at Google?
- CL-USER.net has a wealth of Lisp stuff.
- If you've read all the way to the bottom of this page, you're clearly into Lisp. Here's where you get advanced Lisp packages of all sorts (everything from networking to regular expressions to 3D graphics): QuickLisp. Basically, it's apt-get for Lisp. But you have to know what you're looking for.