Lisp for Java Users

Lisp is the second oldest programming language that is still in use, but surprisingly few developers know much about it. This article attempts to provide Java developers with an understanding of the core ideas of the Lisp language and show how wonderfully simple it can be. This article does not attempt to teach Lisp programming; there are many good articles for that. Instead, most of this article develops Java code for implementing a Lisp interpreter in the hope that Java developers will find this presentation useful and demystifying. The ideas in this article are based on the work of far too many people to list; very few, if any, of the significant ideas presented here are my own.

What is Lisp

Lisp stands for LISt Processing language. The first idea of Lisp is that a nested list notation is very powerful. In fact, anything you want to write in software can be done with nested list notation.

In Lisp lists are formed using balanced parentheses. A very simple list is (). A more complex list is (() () ()). Even more complex lists can be formed, but you need more than just parentheses. Numbers are good, so we allow numbers to be Lisp expressions that can appear in a list. Including numbers means (1 2 3) is also a list.

Experienced Java programmers may want to see these ideas expressed in working code. The following chapters show and explain Java code for reading Lisp data structures and an implementation of a simple Lisp interpreter. The code is not extensive and (hopefully) easy to read. The techniques for parsing, using Java annotations and simple use of Java reflection may be interesting to Java programmers and help explain some Java concepts, in addition to showing some of the keys ideas of Lisp. Links to all of the code are provided so you can download it and run it on your machine.

Continue to Chapter 1