Lisp was the first functional programming language. It was created in 1958 by John McCarthy as a theoretical language, and is widely regarded as ‘way ahead of its time’. Land of Lisp: Learn to Program in Lisp, One Game at a Time! lets you know from the start that though Lisp was ahead of its time when it first burst onto the scene its time has now come.
I thought Land of Lisp was both hilarious and extremely insightful at the same time. The content is delivered with fabulous enthusiasm and some great pictures which the author, Conrad Barski, illustrated himself. Lisp has several variants, any of which could be used as an accompaniment for this book, but the recommended version is Common Lisp.
Not everyone will get the humour of Land of Lisp, and without that I think it will disappoint some readers. As a test to see if this book is for you consider this example; the author presents a program to demonstrate the concept of looping. The game is a self-contained two-dimensional world with plants growing densely in one square “jungle” and sparsely in the remaining “steppes”. The program places into this world some animal objects that have directional “genes” that govern which way they move. These animal objects split into two whenever their life points are higher than a specified threshold, the two new animal objects have near identical directional “genes”. If an animal’s life points fall to zero they die. The book shows the results after several million iterations of the virtual ecology. The results are that the animals fall into two quite distinct categories;
- One type that congregates around the jungle square with directional ‘genes’ that keep it jiggling around the same location.
- The other type traverses the world in fairly straight lines thereby grazing the sparsely planted remainder of the world.
The first animal type is termed “the conservative elephant species” by the author, whilst the second type gets labelled “liberal-minded donkey species”. I know just about enough about US politics to understand what he’s alluding to but his punch line really cracked me up:
“Expanding the simulation to evolve the three branches of government is left as an exercise to the reader”
Land of Lisp presents the core concepts of functional programming (and indeed all programming) through a series of games. Each game presents a specific learning concept, around which the author sprinkles a liberal dash of comedy, some excellent illustrations and a side of common sense coding style. I really associated with the games, they sparked a memory for me of the original Hobbit text adventure game from 1982. There are some light-hearted cartoons between chapters, which drew a considerable level of interest from my children; one had thought the book was originally purchased for him and I had to field several questions from another regarding the rules and regulations of “Orc battle” or “Hunt the Wumpus”.
There are some asides which were excellent learning opportunities, such as the graphviz software or SVG files not to mention using Lisp as a rudimentary web server delivering a pure html stream for the “Dice of Doom”.
Hunt the Wumpus relies on Graphviz for graphical content of the game
Some content was difficult to absorb, which did require a couple of readings. Perseverance is well worth it though, as when you finally get the lisp language you realize it has a natural rhythmic quality that you just have to roll with and ultimately that eases the learning curve. The syntax of Lisp can be learned quickly, but the teachings take some time to sink in. Teaching through games is not an entirely new concept, but this book stands out from all other programming books that I’ve read because of the interactive style. The style of Land of Lisp: Learn to Program in Lisp, One Game at a Time! draws the reader in…you can’t help but learn when there is so much fun going on!