Common Lisp

What is Lisp?

Lisp is a family of general-purpose programming languages with simple syntax and extraordinary power.

The Lisp family of languages is very broad, but all members of the Lisp family share the property that code is data. Lisp code is structured in lists, and Lisp has many routines that can be used to easily manipulate lists and their contents. (In fact, the name Lisp is itself derived from “List Processing”.) Because Lisp code is structured in lists, and Lisp is designed to be capable of manipulating lists, Lisp programs can manipulate source code as if it were purely data. This allows programmers to add new syntax to Lisp in order to create a domain-specific language that can be used as if it were part of the core language.

More specifically, Lisp code is structured using s-expressions, which are lists surrounded by parentheses. For example, a function call is written as a list that starts with the function name and ends with the arguments to the function. A function fn that takes two arguments x and y could be called using the form (fn x y).

What is Common Lisp?

There is no single definitive implementation of Common Lisp. This is because Common Lisp is not a language defined by a person, but is rather a language defined by a standard. This is both a strength and a weakness. A strength, because any compliant implementation of Common Lisp is guaranteed to support the functions defined in the ANSI standard, but also a weakness, because a standard can slow or stop the invention of ideas for new features and constructs.

One oft-seen criticism of Common Lisp is that because it is defined by an ANSI standard, Common Lisp is “large” or “bloated”; however, one might just as well call the C programming language large or bloated. Both Lisp and C have very small conceptual cores and very comprehensive and useful standard libraries. A more valid criticism of Lisp is that the ANSI standard does not cover areas that have become important since the standard was created (e.g., network programming, SQL database interaction, persistence, and concurrency). There are many implementations of Lisp that are compliant with the ANSI standard and can therefore properly be called “Common Lisp”. Each of these implementations implements different network programming interfaces and concurrency constructs, which leads to a situation in which it is possible to have a fully compliant Common Lisp implementation that nonetheless diverges from other Common Lisp implementations with respect to important programming interfaces.

This is not as dire a situation as it may seem at first glance, however. Common Lisp supports a variety of simple ways to conditionally detect and run code for different implementations of Common Lisp, and most common useful libraries created for Common Lisp will support the implementation chosen by the programmer.

Common Lisp is not the only form of Lisp. There are many other popular variants of Lisp such as Scheme (which has a much smaller core specification than Common Lisp) and Clojure (a Lisp that targets the Java Virtual Machine). There are advantages and disadvantages to using any member of the Lisp family, and Common Lisp is not necessarily “better” or “worse” than any other member of the Lisp family — it simply happens to be my preferred Lisp.

Discovering Lisp

John McCarthy invented Lisp in 1958, which means that the Lisp family of languages is the second-oldest high-level programming language family used today. (Fortran is older, and is also still widely used.)

It may not be easy to understand why Lisp has stuck around so long. After all, no one writes new programs in ALGOL or APL any longer, do they? (Well, perhaps they do, but there are millions of Lisp-oriented webpages, compared to tens of thousands of ALGOL- and APL-oriented pages.) Lisp is older than both those languages, and yet it remains widely used.

Here's one take on why this might be:

“Part of what makes Lisp distinctive is that it is designed to evolve. You can use Lisp to define new Lisp operators. As new abstractions become popular (object-oriented programming, for example), it always turns out to be easy to implement them in Lisp. Like DNA, such a language does not go out of style.”

— Paul Graham, ANSI Common Lisp

Here's another take:

“Programming in Lisp is like playing with the primordial forces of the universe. It feels like lightning between your fingertips. No other language even feels close.”

— Glenn Ehrlich, Road to Lisp

You don't hear this sentiment echoed about, say, Java. Lisp is simply a different programming experience.

And yes, it really does feel like lightning.

Getting Started

Peter Seibel's book Practical Common Lisp provides an excellent introduction to Common Lisp. If you plan to work through Practical Common Lisp, you can use a customized version of Lisp in a Box called Lispbox. There are many other Lisp books available to download or buy. Some of them are in the Resources Made by Others side panel.

Saving the World with Lisp

Can we really save the world using Lisp? Well, probably not using only Lisp. However, Lisp's interactive programming capabilities allow the programmer to incrementally (or perhaps, organically) grow a program closer and closer to the asymptotic perfect solution. So while we may not save the world, we can certainly solve some big and difficult problems.

There are a lot of other programming languages that can make similar claims. Python and Ruby are obviously contenders in this space, and have been used by many entities (hi, Google) to solve significant problems and to create amazing things. If you prefer those languages (or just hate Lisp's parentheses) that's fine. We need lots of people solving problems, and you'll be much better at solving problems if you use a language that works for you.

Give Lisp a try, though. You might find that it surprises you.