by Adam Michael Wood
December 12, 2018
December 12, 2018

Lisp Programming

Lisp Programming

Lisp is a family of programming languages, first conceived in 1958 and finally implemented in 1961. This makes it is the second oldest language still in common use, after Fortran.

But while Fortran continues to slowly fade away, Lisp is still a very important part of the computer science landscape.

Lisp is unique in several ways. For one thing, every expression in Lisp is a list, one of two primary data types in the language. (This is why it is called “Lisp.”)

Since the code itself can be evaluated as a datatype in the language, Lisp lends itself to recursion and introspection.

Moreover — unlike most other languages — Lisp code is a human-readable version of the actual data structure as it is processed by the underlying Lisp system.

This means there is a high-degree of similarity between how a programmer thinks about a program, and what the program is actually doing “under the hood.”

Lisp can be used for any number of applications and problem domains, but it is especially useful for Artificial Intelligence and Machine Learning.

Lisp Standalone Implementations

It is a sign of Lisp’s usefulness that there are so many different versions of it. These include standalone languages and well as languages built inside applications. We’ll discuss both below.

Common Lisp

Common Lisp is one of the most popular dialects of Lisp. It was first released in 1984, and became an ANSI standard one decade later.

It was an improvement on Maclisp. But it wasn’t the only Lisp version working off Maclisp; there were several others. But Common Lisp’s commitment to standardization made it ultimately the most successful.

Common Lisp Resources

If you are interested in Common Lisp, there are many ways to learn it.

Books

There are very few online tutorials for Common Lisp, so if you really want to learn the language you’ll need to consult one or more books. Fortunately, there are online editions of many of these.

Many of the most important and influential books on Lisp were written in the 1970s and 1980s, and are now out of print and hard to find. Several of these books have been made available online, and you can find links to them below.

Online Resources

Of Historic Interest

Lisp is a historically interesting language. Its development is closely tied to the development of Artificial Intelligence and machine learning. It is also one of the most unique languages in common use, with a syntax and internal logic wildly different than most other languages.

These differences are part of ongoing debates within the computer science community about the nature of computation and the proper grammar for programming.

Anyone who is taking the time to learn Common Lisp today should make it a point to explore some of the language’s history.

John McCarthy (1927-2011) was a long-time Professor of Computer Science at Stanford University. His home page is a treasure-trove of interesting articles on AI, Lisp, theoretical computer science, and related topics.

Learn Lisp

There are not very many online tutorials for Common Lisp, as there are for more popular languages like PHP or Ruby. However, there are a lot of books on Lisp which have been released as online editions.

Many of these were written in the 1970s and 80s, though there are certainly some more contemporary resources as well.

Required reading:

Lisp Reference and Documentation

More than even most other languages, if you start working with Lisp you will find yourself needing to consult reference material on a frequent basis. Here are some of the more commonly used Common Lisp reference works available online.

Special Topics in Lisp Programming

Lisp is, on its own merits, a fairly specialized language. Here are a few resources on particularly specialized issues in Common Lisp.

Lisp Tools

If you want to accomplish anything of major substance with Common Lisp, you’ll need a larger ecosytem of language support — libraries, plugins, development tools, frameworks.

Here are some of the most popular tools that Lispers use to get things done.

  • ACL2 — A Computational Logic for Applicative Common Lisp
  • Reader Macros in Common Lisp — Reader macros allow you to create entirely new syntax on top of Lisp
  • Quicklisp — Library manager for Common Lisp
  • Clack — A web application environment for Common Lisp. Several web application frameworks have been built on top of it:
  • Parenscript — Translates Common Lisp to Javascript
  • jscl — Another Common Lisp to JavaScript compiler
  • Roswell — Command line installer for Common Lisp
  • CommonQT — An Common Lisp extension for QtTools, providing a GUI solution.
  • CLML — Common Lisp Machine Learning library
  • MGL — Anoth machine-learning library
  • Antik — library providing tools for scientific and engineering computation
  • Crane — an ORM for Common Lisp.
  • cl-dbi — Database abstraction layer
  • CEPL — Graphics library. (Check out their extensive video tutorial series.)
  • Iron Clad — Cryptography tools.
  • SLIME — The standard IDE for Common Lisp.
Lisp Culture and Community

More than any other language, Lisp has its own culture — unique lore, humor, and tradition. Some of this goes back to its roots in computer science departments of universities.

Additionally, some of it is related to early geek hacker culture, and some of it is a result of the peculiarities of the language itself and the types of applications it is commonly used for.

If you really want to understand Lisp, you can’t just learn the language — you have to learn the culture and become a part of this (weird and wonderful) community.

Required Reading:

  • Gödel, Escher, Bach: An Eternal Golden Braid, by Douglas R. Hofstadter — This book is not directly related to Lisp (though it does talk about it a little bit). But it’s a hugely important cultural and intellectual touchstone for people in a number of different domains that Lisp inhabits: artificial intelligence, machine learning, mathematical logic, and recursion. This book will change the way you think, and you’ll end up thinking more like the kind of person who uses Lisp.
Common Lisp Implementations

Lisp is an idea, and Common Lisp is a language — it is not a specific technology. The following are some of the more popular implementation of Common Lisp.

Videos

Learn about Lisp by watching. These videos run the gamut from basic tutorials to in-depth explorations of Lisp logic and philosophy.

Lisp is not a single language, but a family of languages — an idea about how to do computer programming. Common Lisp is the most popular implementation of Lisp, but several others exist.

The major dialects of Lisp are:

  • Scheme — Scheme is the leading “competitor” to Common Lisp.
  • Clojure — Clojure is a Lisp dialect that is currently gaining popularity. It is built to run in the Java Virtual Machine.

Common Lisp FAQ

What is Lisp?

Lisp is a family of computer programming languages which were first developed in the late 1950s. Lisp stands for List Processing, a name referring to the fact that the languages uses lists as its primary data structure, and also for its programming syntax.

What is Common Lisp?

Common Lisp is a dialect of Lisp that was developed in the early 1980s, as an attempt to create a single (common) version of Lisp. It is one of the two most popular versions of the language (along with Scheme).

What is Lisp used for?

Lisp can be used for any type of application, but it is of particular interest for Artificial Intelligence, machine learning, and other forms of advanced programming which require recursive logic.

There are at least two reasons for this.

First, Lisp’s primary data structure (the list) is also the structure of its programming syntax. That is, data and instructions about data take the same form. (This is called homoiconicity.)

This means that Lisp can be used to analyse its itself, or to modify itself. Many experts in the field of Artificial Intelligence, as well as many philosophers and thinkers in related domains, consider this type of recursive introspection to be the foundation for real, self-aware intelligence. Moreover, the ability for a program to change itself based on input is the essence of machine learning.

A second reason for Lisp’s popularity in AI is that the control syntax for the language is closely analogous to the computational logic underlying it. This gives Lisp programmers a much deeper insight into how a computer is actually interpreting the logic and syntax of the program than is possible with other languages.

Clojure

Clojure is a relatively new (2007) programming language. It is a dialect of Lisp, designed to run on the Java Virtual Machine.

What is the Java Virtual Machine?

The JVM is a virtual computer that compiles and runs Java and other languages. JVM is an idea, not a specific piece of software — one of the most popular implementations of the JVM is HotSpot from Oracle.

The idea behind Java and the JVM is that you can write a program in Java (or another supported language), and compile it for the JVM. Then, you can run it on any computer that runs a JVM. This makes it extremely portable — you can write code once, and run it anywhere.

Clojure: Lisp on the JVM

Java is everywhere, which means that Java Virtual Machines are everywhere. Creating a version of Lisp that runs on the JVM made it possible to run Lisp anywhere. That was the primary motivation for creating Clojure, and a great reason to learn the language.

Another benefit is that Clojure provides access, via the JVM, to countless tools and third-party libraries written in Java. This gives Clojure a development ecosystem that is more powerful than those previously available to any Lisp dialect.

Clojure Tutorials

Other Resources for Learning Clojure
  • Try Clojure, is an online Clojure interpreter, letting you get some experience Clojure in the browser before installing it locally.

  • ClojureTV has video tutorials and live talks about a variety of Clojure development topics.

  • 4clojure is an interactive learning site with programing exercises in Clojure.

  • Full Disclojure is another video channel with tons of great Clojure tutorial videos.

  • A Clojure Newbie Guide is a helpful resource pointing the new Clojure developer to all the essential tools and resources that form the Clojure ecosystem.

Clojure Reference Material

  • The Clojure Style Guide is a community-written guide to best practices for writing clear, maintainable Clojure code.

  • ClojureDocs and Grimoire are both unofficial companions to the official documentation, providing community-sourced commentary and examples.

  • Clojure Cheatsheet is a quick reference page for all the little things you just have to remember.

Community and Ongoing Learning

Books about Clojure

There are a lot of books about Clojure. Here are the ones that the Clojure community recommends again and again:

Should I learn Clojure?

Probably.

It is a widely-accepted truism that every developer should learn Lisp, even though you probably won’t use it. But now that the power of Lisp has been combined with the ubiquity of Java, its a language that is both good to learn and exceptionally useful.

Good Clojure developers are highly sought after and well paid, and the language is growing in popularity.

If you’re looking for programming skills to set you apart from other developers, Clojure is one of the best tools to add to your kit — and to your resume.

Scheme

If you are a bit older, and you attended an introductory computer science course at high school or university, it is likely that you used the good old Scheme programming language in that course.

Brief History of Scheme

In order to better understand the history of Scheme, we have to look at the very early stages of modern computing. The development of Scheme was influenced by two earlier, very different predecessors: Lisp and ALGOL programming languages.

Lisp was created in 1958 by Massachusetts Institute of Technology’s (MIT) John McCarthy. Scheme was derived from Lisp, using its general semantics and syntax. In addition, Scheme borrowed from ALGOL. It had been developed by a committee of European and American computer scientists at a meeting in 1958, at ETH Zurich. Scheme used its block structure and lexical scope.

In 1973, MIT’s Guy L Steele and Gerald Jay Sussman started an attempt to implement Carl Hewitt’s Actor model in the Lambda calculus. They did this by writing a tiny Lisp interpreter in MacLisp and adding mechanisms for creating actors and sending messages. During their work, they realized that they created a very small and capable dialect of Lisp, and they named it Scheme.

In 2003, the Scheme workshop began a new standardization process for Scheme, and eventually released ratified standard R6RS in 2006. The last stable release of Scheme is ratified standard R7RS from 2013.

Scheme Features

Scheme is a primarily functional programming language, with lists as the main data structure, and support for first-class functions. It is a simple, minimalistic, and easy to implement programming language. This minimalist philosophy has led to wide divergence between practical Scheme implementations, to the extent that the Scheme Steering Committee calls it “the world’s most unportable programming language” and “a family of dialects” rather than a single language. Unlike earlier derivatives of Lisp with dynamic scoping, Scheme is lexically scoped (an influence from ALGOL).

In Scheme, blocks are implemented with the following constructs: let, let* and letrec. This block structure is also inherited from ALGOL. Iteration construct do is used in Scheme, and support for iteration using tail recursion is also provided. Continuations in Scheme are first-class objects and they are supported by the call-with-current-continuation Scheme procedure (also known as call/cc). In Scheme, all data and procedures share a common namespace, and input and output are based on the port datatype.

Numerical tower is a set of complex and rational numerical datatypes specified and implemented in Scheme. Delayed evaluation is supported in Scheme through the delay form and the force procedure.

Scheme Implementations and Uses

Because of its simplicity and minimalism, Scheme libraries became very popular with programming language designers, educators, and hobbyists. This resulted in many different implementations and dialects of Scheme. The traditional Lisp-style read-eval-print loop is supported in most Scheme implementations, and some also compile scheme programs to executable binaries.

The simplicity of Scheme implementations also makes it a popular choice for adding scripting capabilities to larger systems. In addition, JScheme and Kawa implementations of Scheme provide integration with Java classes.

Scheme is primarily used in education. In many introductory computer science and program design courses to demonstrate the basics of computer programming. Other notable uses of Scheme include Google App inventor for Android, GIMP graphics editor, Document Style Semantics and Specification Language (DSSSL), and so on.

Learning Scheme

Because of the widespread educational use of Scheme, learning it and finding resources for learning should not pose a problem. There are many available learning resources, both free and commercial, and we singled out a few of them.

Scheme Courses and Resources

Since Scheme is a minimalistic and streamlined programming language, it is relatively easy to master. With these courses and tutorials, you will probably be able to start programming in Scheme in no time.

  • Structure and Interpretation of Computer Programs is MIT’s introductory course 6.001 with many useful resources for Scheme including video lectures, online textbooks, projects, transcripts, and selected lecture notes.
  • DrScheme is an integrated development environment (IDE) for writing, debugging and analyzing Scheme programs, also used in education.
  • Pilo Visual Tools for Scheme (PVTS) is a basic Scheme interpreter implementation with visualization tools. It is written in Java and it has very limited interpreter capabilities, with the sole purpose to display Scheme code graphically as a learning aid.
  • Schemers.org has a nice collection of documentation and introductory texts for Scheme.
Scheme Books

Numerous Scheme books are available, and many of them are free and used in educational courses. These can be very helpful if you are just starting to learn the Scheme programming language.

  • Structure and Interpretation of Computer Programs by Abelson, Sussman and Sussman is an excellent computer science book used in introductory courses at MIT. This is one of the bibles of the Lisp and Scheme world and it is available online for free, from MIT Press.
  • How to Design Programs: An Introduction to Computing and Programming by Felleisen, Findler, Flatt and Krishnamurthi provides a very nice introduction to programming logic. It is free and available online, published by MIT Press.
  • The Scheme Programming Language, Fourth Edition by R Kent Dybvig is intended to provide an introduction to the Scheme programming language, but not an introduction to programming in general. It is free and available online, published by MIT Press.
  • The Little Schemer – 4th Edition by Friedman and Felleisen introduces computing as an extension of arithmetic and algebra, and programs as recursive functions. This book is not free.
  • The Seasoned Schemer also by Friedman and Felleisen, informs the reader about additional dimensions of computing: functions as values, change of state, and exceptional cases. This book is not free.
  • How to Use Scheme: Writing Scripts and Programs with PLT Scheme by Felleisen, Findler, Flatt, Krishnamurthi, Steckler will introduce you to some pretty basic ideas, such as file input and output, to more advanced things, like simple GUI design and Web scripting aspects of Scheme. It is freely available online.

Is Scheme Right for You?

Scheme is not only a good way to learn how to program, but also a good way to begin studying computer science. These reasons should get you heading in the right direction.

Lisp Application Implementations

Lisp is so useful that it is often used as the scripting language for applications. The two biggest are the text editor Emacs and the computer-aided design (CAD) application AutoCAD. We’ll look at both of them below.

AutoLISP

If you use computer-aided design (CAD) software, such as AutoCAD, Bricscad or IntelliCAD, at some point you are likely to need additional customization or automation features in your CAD environment.

This is where AutoLISP steps in. AutoLISP is a simple, lightweight programming language built specifically for use with CAD software.

A Brief History of AutoLISP

AutoLISP is a dialect of the Lisp programming language, customized and streamlined for use in the AutoCAD environment.

Lisp is a family of programming languages dating back to 1958. The name Lisp is derived from “List Processor,” and linked lists are one of Lisp’s major data structures.

AutoLISP was first introduced in Autodesk’s AutoCAD version 2.18 in 1986, and was continuously improved in new releases up to release 13 in 1995, when Autodesk halted AutoLISP development in favor of more modern development environments like VBA or .NET.

Despite this, AutoLISP has remained the primary customization language for many AutoCAD users.

In 1997 Autodesk released AutoCAD 14, and introduced Visual Lisp as a commercial add-on for AutoCAD. Visual Lisp includes an integrated development environment (IDE), debugger and compiler, and ActiveX support.

With the release of AutoCAD 2000 in 1999, Visual Lisp was incorporated in AutoCAD as a replacement for AutoLISP. Since then, major enhancements to Visual Lisp have been halted by Autodesk in order to focus on VBA, .NET, and C++.

Visual Lisp and AutoLISP remain supported in AutoCAD to this day, while support for VBA versions older than 7.1 has been dropped as of January 31, 2014.

Many other CAD software vendors also adopted support for AutoLISP in their own products, due to the big user base, as well as many utilities and applications available in AutoLISP.

Why Do People Still Use AutoLISP Instead of C++?

If you use the full version of Autodesk AutoCAD, the AutoLISP compiler is already included in AutoCAD and ready to use. There is also a nice IDE onboard — Visual Lisp. Please note that AutoCAD LT editions do not have built-in support for AutoLISP.

Most AutoCAD users, or users of similar CAD solutions, are not familiar with programming and programming languages, so learning C++ to create a simple program or a function for automation in AutoCAD would not be practical.

AutoLISP is simple, streamlined, and much easier to use and learn than C++ or Visual Basic, and everything you need to start programming is already included in AutoCAD.

Programs and utilities written in AutoLISP are easily accessed and executed from AutoCAD. These are the main reasons that make AutoLISP the best option for customizing AutoCAD by its users.

AutoLISP Features

AutoLISP is an interpretive language, it is not compiled, so it can be stored in an ASCII text file, loaded, and then executed directly within AutoCAD.

Almost all operations that you perform manually in AutoCAD can be performed automatically using AutoLISP.

AutoLISP has a rich set of functions that you can use to perform any activity in AutoCAD, like general programming functions for variable manipulation, decision control, loops, arithmetic operations, error handling and function handling.

It also has specialized functions in a number of areas such as: geometry, display control, query and command, user input, and object handling.

AutoLISP also features a Dialog Control Language, a built-in GUI mini-language for creating modal dialog boxes with the automated layout in AutoCAD. All platforms that can run AutoCAD support AutoLISP as well.

Learning AutoLISP

There are certain factors that can make learning AutoLISP easier.

If you are an experienced AutoCAD user, learning AutoLISP will be easier for you. AutoLISP is essentially a way to control AutoCAD, so the better you know AutoCAD, the better you will know what needs to be done to control it automatically.

AutoLISP Tutorials

AutoLISP is a very simple language to learn, and probably the most productive out of different Application Programming Interfaces (APIs) built into AutoCAD. With these tutorials, you will probably be ready to write your own useful programs in no time.

AutoLISP Books

Numerous books dealing with AutoLISP and its use in AutoCAD are widely available. You may find some of these books very helpful in learning how to program in AutoLISP, although we would suggest going through the online tutorials first.

  • AutoLISP Programming: Principles and Techniques by Rawis and Hagen provides practical and easy-to-follow instruction in mastering the AutoLISP programming language.

  • AutoCAD Platform Customization: User Interface, AutoLISP, VBA, and Beyond by Lee Ambrosius is a comprehensive guide to streamlining and personalizing the AutoCAD platform. The AutoLISP and VBA programming languages open up a myriad of customization options, and this book provides expert guidance toward applying them to AutoCAD, Civil 3D, Plant 3D, and other programs based on the Autodesk AutoCAD platform.

  • AutoCAD expert’s Visual LISP by Reinaldo Togores: shows Lisp programming techniques, including the use of the Visual Lisp Integrated Development Environment, explained starting from scratch.

Are You Ready for AutoLISP?

Even though AutoLISP is derived from Lisp, a very old programming language, AutoLISP still remains a very valuable tool for AutoCAD users.

AutoLISP is still the tool of choice for customization and automation in AutoCAD and other CAD software with AutoLISP support.

Emacs Lisp

If you use GNU Emacs or any other similar Emacs text editor, you have probably heard of Emacs Lisp. Emacs Lisp is the programming language used to develop and code most of the editing capabilities of the GNU Emacs text editor. Emacs Lisp is also referred to as Elsip.

Essentially, Emacs Lisp is used to customize and extend the capabilities of the GNU Emacs text editor.

Brief History of Emacs Lisp

Emacs Lisp is a minimalist dialect of the Lisp programming language used in the GNU Emacs and XEmacs text editors. Lisp stands for “List Processor,” and represents a family of programming languages dating back to 1958.

Richard Stallman, the founder of the GNU Project, created the GNU Emacs text editor.

First released in 1985, GNU Emacs version 13 introduced the use of Emacs Lisp as its own extension language. Emacs Lisp was largely inspired by the Maclisp dialect of the Lisp programming language.

The latest stable release of GNU Emacs is version 24.5, and it was released in April 2015.

Emacs Lisp is an integral part of the GNU Emacs and it runs on all platforms supported by GNU Emacs — GNU, GNU/Linux, FreeBSD, NetBSD, OpenBSD, Mac OS X, Microsoft Windows, and Solaris.

Both Emacs Lisp and GNU Emacs are open source and free. They are published under the GNU General Public License, and the source code is freely available for examination, modification, and redistribution.

Who Uses Emacs Lisp and GNU Emacs?

With today’s modern Integrated Development Environments (IDEs), writing code in a specialized text editor like GNU Emacs can seem very odd at first glance.

However, for a seasoned user, GNU Emacs has many powerful code editing capabilities that most modern IDEs do not have.

GNU Emacs is described as an extensible, customizable, self-documenting, real-time display editor, and almost all of these powerful features come from its integrated Emacs Lisp interpreter.

Modern IDEs focus on GUI and visual elements, and are primarily mouse controlled. Unlike them, GNU Emacs focuses on keyboard input and powerful text editing features, so it is better suited for programmers writing pure code than most modern IDEs.

Every popular programming language is supported in GNU Emacs. What’s more, Emacs Lisp kicks-in as a powerful tool for expanding and customizing GNU Emacs.

Emacs Lisp Features

Since the Emacs Lisp programming language was specifically designed to be used in an editor, it provides special features for parsing and scanning text, handling sub-processes, buffers, displays, files, and so on. Editing commands are functions that can be called from Emacs Lisp programs.

Emacs Lisp features show a close relation to the Maclisp dialect. Emacs Lisp uses a dynamic scope by default, with support for both imperative and functional programming methods, focusing on providing data structures and features specific to its use in a powerful text editor.

Static scope is available as an option as of version 24. It can be activated by setting the variable lexical-binding. Note that Emacs Lisp does not support tail-call optimization, so tail recursions can lead to stack overflow errors.

Emacs Lisp can also be used as a scripting language for GNU Emacs, called from the command line or from an executable file, with all editing functions available to the program.

The GNU Emacs user interface is not displayed when it is running in batch mode with Emacs Lisp used for scripting, so it behaves more like a standard Unix tool.

Your Development Environment

To start using Emacs Lisp, you will need to install the GNU Emacs text editor. It is a very simple process.

Just head over to the Gnu.org Emacs download page and follow the instructions on downloading and installing GNU Emacs on your system. GNU Emacs supports the following platforms: GNU, GNU/Linux, FreeBSD, NetBSD, OpenBSD, Mac OS X, Microsoft Windows, and Solaris.

Learning Emacs Lisp

Naturally, learning Emacs Lisp will be easier if you have previous programming experience, especially in some of the functional programming languages derived from Lisp.

General programming experience is welcome as well, because veteran coders tend to know their text/code editors inside out.

Emacs Lisp Tutorials and Resources

Emacs Lisp is a minimalistic and easy-to-learn programming language, but due to its relatively limited, niche appeal, there aren’t that many online resources. We chose a few tutorials and learning resources that should be useful if you are just getting started with Emacs Lisp:

Emacs Lisp Books

There are also a number of Emacs Lisp books out there. Some of them can be very useful, but we still suggest that you try online tutorials and resources free of charge. If you need more resources, you can buy a book or two.

If You Use Emacs, You Need Emacs Lisp

GNU Emacs was designed as a text editor with support for customizations using Emacs Lisp.

However, GNU Emacs became an almost full-blown IDE thanks to the power and extensibility provided by the Emacs Lisp programming language.

It’s a powerful, but highly specialized programming language. It’s not something the average developer needs to master, but in some niche applications, Emacs Lisp is still widely used, and this is unlikely to change anytime soon.

Conclusion

We’ve barely scratched the surface of the world of Lisp. But as you can see, it is an extremely useful language to know, whether you are building applications or just trying to make your text editing easier.


Other Interesting Stuff

We have more guides, tutorials, and infographics related to coding and development:

What Code Should You Learn?

Confused about what programming language you should learn to code in? Check out our infographic, What Code Should You Learn?

It not only discusses different aspects of the languages, it answers important questions such as, “How much money will I make programming Java for a living?”


Main text written by Adam Michael Wood with additional material by Nermin Hajdarbegovic. Compiled and edited by Frank Moraes.

About Adam Michael Wood

Adam specializes in developer documentation and tutorials. In addition to his writing here, he has authored engineering guides and other long-form technical manuals. Outside of work, Adam composes and performs liturgical music. He lives with his wife and children in California.