The first version of Lisp was specified as early as 1958. This makes the language one of the oldest programming languages still in use. Despite its age, the language has numerous structures that are either not at all or not too long to be found in many other languages. These include, for example, lambda expressions and macros.
- Kubernetes in Action
- Common Lisp: A Gentle Introduction to Symbolic Computation
At first glance, Lisp code seems unusual: In Lisp, everything is represented by lists, which applies not only to data, but especially to code. The list
'(2 3 5 7 11)
contains the first five prime numbers, while the list
(+ 2 3 5 7 11)
calculates the sum of them. If you want to apply the
+ function to the data list, this is possible with the
(apply #'+ '(2 3 5 7 11))
Choosing the right book
A big advantage of such an old language is that there is already countless literature (sometimes Lisp's problem is to find the right book in an antiquarian bookstore). A particularly remarkable example is Common Lisp: A Gentle Introduction to Symbolic Computation by David S. Touretzky, first published in 1990.
The book begins with the basic data type of Lisp par excellence, the list. The first three chapters deal with the structure of lists, their internal management and a suitable notation. Unexpectedly, the author does not use code at first and instead explains all concepts with diagrams. This makes the theoretical foundation vivid, so that the book reads entertainingly despite the depth of detail.
In the fourth chapter, in which code is then also written, he introduces the various conditions and logical operators of Lisp. Especially with the macros
The fifth chapter introduces variables and introduces a programming style based on side effects for the first time. This chapter is particularly interesting with the background of the current renaissance of (pure) functional programming: Here, too, the underlying concepts are significantly older than one would generally expect. The sixth chapter then deals with various ways of using lists as a basis for other data structures, for example for sets, tables and trees.
The following two chapters are, if you like, two sides of the same coin. They deal with the processing of all elements of a list, whereby the seventh chapter chooses an applicative approach, the eighth, on the other hand, a recursive one. These two chapters also offer a lot of potential for developers who do not work with Lisp.
Theory and practice
The ninth chapter deals with the input and output of data, for example using the terminal or files. Furthermore, the chapter introduces streams, which is another concept that is gaining relevance again today.
After discussing the applicative and recursive programming, chapters 10 and 11 deal with procedural programming, introducing classical loops that produce side effects. The twelfth and thirteenth chapters are then devoted to creating custom types and some higher types that Lisp includes by default, such as arrays, hash tables and property lists.
The fourteenth and final chapter finally introduces programming with macros for meta programming. With them it is possible to extend Lisp's own syntax and to implement DSLs, for example.
What is outstanding is that every single chapter strikes the right balance between a general introduction to the subject and profound details: In this way, the book not only appeals to beginners, but is also suitable as an extremely valuable reference for a long time.
Furthermore, it is helpful that each chapter is peppered with numerous small practical tasks, which are usually to be implemented with a few lines of code, but for their solution one must first do some mental work. This makes it all the more astonishing to see how compact the implementation in Lisp often is compared to other languages.
All in all, Common Lisp: A Gentle Introduction to Symbolic Computation is an exceptionally well written book. It is suitable as an introduction to the Lisp language as well as an introduction to programming in general.
Dealing with the language is fun and actually broadens one's own horizons. Not only the chapters on the different paradigms contribute to this, but also the outlook in the last chapter, which only gives an idea of what power is available with the help of macros.