Home  Lisp

Lisp FAQs

why?
parentheses
other features
dialects
implementations
IDEs
drawbacks


 
Why Lisp?

In a word: metaprogramming. Lisp has the best metaprogramming facilities of any language, period. Metaprogramming means having your program write (parts of) itself. Any commonly used loops, function or data-structure definitions, or any other patterns at all, can be encapsulated in a macro that inserts the desired code into your program without your having to retype or copy & paste it.

Why all the parens?

Same answer as above: Lisp's almost mindlessly simple syntax is what makes metaprogramming with macros so easy. Each pair of matching parentheses marks a list structure that defines part of the program. These lists can be manipulated by macros at compile time as easily as regular lists are handled at runtime. You never have to repeat a structural pattern in your code. All you have to do is write a macro that expands into that pattern, and call the macro as needed.

Is that all?

But wait—there's more!

  • Lisp's read-eval-print loop (REPL) makes it easy to quickly experiment with new code before adding it to the main program.
  • Per-file compilation shortens compile times.
  • Common Lisp's powerful condition system allows much better control over exceptional situations than do most exception systems.
  • Mandatory parentheses obviate the need to remember operator precedences.
  • Dynamic typing is more expressive than traditional static typing systems, which require explicit type declarations, and don't support polymorphic functions (which apply to more than one type of arguments).
  • Multiparadigm support for functional, procedural, and object-oriented programming make Lisp unusually expressive.
  • The CLOS multiple-dispatch object system is more expressive than the traditional object systems in Java and C++.

Which dialect?

Short answer: Common Lisp for real-world code, Scheme if you want something easy to learn.

Technically speaking, Lisp is a whole family of languages. Back in the early days, there were many competing dialects, which caused confusion. In the 1980s and '90s, the major dialects were combined and standardized into a single dialect. That dialect is Common Lisp (CL). Common Lisp is used widely throughout the world, in industry, government, and academia. If you want to write serious real-world code, CL has more language features and library support than any other dialect of Lisp.

While CL is great for big projects, it's a huge language. Scheme is a closely related language that's popular in education. It's much smaller, much simpler, and easier to learn. Scheme is the language used in SICP.

E-Lisp is used in the powerful text editor Emacs, and Autocad Lisp is used in computer-assisted design (CAD).

Arc is a new dialect just released this year (2008) by Paul Graham. It's optimized for web applications, and is intended to be more concise and better designed than CL. It's still in its infancy, but is popular with programmers coming from backgrounds in other languages.

Qi is an extremely modern, sophisticated AI language built on top of CL. It has an optional static typing system that's more powerful than Haskell's, and includes a built-in implementation of Prolog. Qi is also a very young language.

Which implementation?

If you just want something to get started with, SBCL is the most popular free implementation for Linux and Unix. If you're using Windows, CLisp will work better. There are also other implementations, both free and commercial.

Which editor/IDE?

By far the best development platform for Common Lisp is Emacs and Slime. Emacs has automatic highlighting, indentation, search, and other editing facilities for Lisp. Slime allows you to compile and run programs, expand macros, and lots of other things, in just a couple keystrokes.

Is Lisp perfect?

No, there are trade-offs.

  • Mandatory parentheses make individual expressions clunky. Macros and first-class functions compensate for this in large programs, but one-liners can be wordy. In the case of arithmetic operators, the syntax looks unusual, so many people take a while to get used to it.
  • Dynamic typing doesn't provide the compile-time checking of static type systems, and modern statically typed languages like Haskell, OCaml, and SML have type inference systems that minimize the verbosity of type declarations, and have powerful type systems that support polymorphic functions. Haskell's type system is especially powerful, although Qi, which is built on top of Common Lisp, has an even more powerful type system, which is also optional, and also allows access to CL's macro system.
  • Common Lisp is an old language. Lisp could use a lot of modernizing, especially for web programming.
  • Haskell and the ML family have pattern matching and partial function application built in. although this can mostly be implemented in Lisp with libraries.

© 2008 Daniel S. Bensen   Home   About   Site map