Paradigms of artificial intelligence programming: Case studies in Common Lisp

Paradigms of artificial intelligence programming: Case studies in Common Lisp

nil

Peter Norvig. Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp. Morgan Kaufmann. 1992.

An absolute classic of both AI and Lisp, and really two books in one. The applications presented cover the entire range of “classic” AI up to the late 90s: expert systems, logic programming, symbolic mathematics, knowledge representation, constraint programming, game search, syntax-driven natural language processing, and more.

It uses Lisp as the programming vehicle, and doesn’t shy-away from depth, dealing with the effects of garbage collection (and how to program effectively in its presence), the effects of different representations, low-level optimisation and disassembly, and all the approaches one needs to use Lisp in real, scalable practice.

Common Lisp recipes: A problem-solution approach

Common Lisp recipes: A problem-solution approach

nil

Edmund Weitz. Common Lisp Recipes: A Problem-Solution Approach. Apress. 2016.

An extensive list of recipes for using common data structures, how the differ in Lisp from the equivalents in other languages, and what novel features Lisp has to offer. A great place to start when moving away from being a beginner, and for dipping into in search of solutions.

It’s probably strongest on the “gotchas” and dangers that Lisp presents, but also has a lot to say about coding style and code optimisation.

The Common Lisp condition system

The Common Lisp condition system

nil

Michał “phoe” Herda. The Common Lisp Condition System. Apress. 2020.

An enormously detailed look at the condition system, sometimes regarded as the Lisp equivalent of exception-handling in other languages.

But that’s massively unfair to the condition system, which is really a way to deal with non-local transfers of control in the most flexible way possible. Exceptions are just one type of this, and the condition system aims to separate three aspects that are often combined in other languages: detecting and signalling a condition, responding to a condition, and deciding on the binding between the two, possibly combining responses differently in different contexts. It’s a set of concepts that are in many ways foreign to a lot of other languages, and so justify the detail for those occasions when these techniques are appropriate: deciding when they are appropriate is non-trivial, a matter of both functionality and style.

Anatomy of Lisp

Anatomy of Lisp

John Allen. Anatomy of Lisp. McGraw-Hill. ISBN 0-07-001115-X. 1978.

This is a hard book to characterise. It’s simultaneously an introduction, a collection of advanced (for the time) programming techniques, and a guide to some very low-level implementation details. It contains a lot of the usual introductory material, but then delves into different representational choices for the basic data structures – lists, but also arrays and hash tables as well as Lisp code itself – and for the frames needed to represent function calls. It the tackles interpretation versus compilation, and even topics such as cross-compilation and just-in-time or memoised compilation.

It’s impossible to read this book without thinking of SICP, and indeed I think in many ways it’s a direct precursor. (It’s referenced a couple of times in SICP.) It has that same combination of high-level, semantics-driven programming combined with descriptions of underlying mechanisms. Where I think it mainly differs is that it mixes representations, using a more semantics-driven notation and explicit assembler instructions rather than sticking with Lisp variants for everything. It’s only when you see the two approaches side by side that you realise how clear Lisp can be in radically different contexts..

Another important book was published in 1978: Kernighan and Ritchie’s The C programming language. The two books share a certain low-level focus, but come to very different conclusions about the correct approach to dynamic storage, as the following footnote by Allen (slightly edited for clarity) illustrates:

Experiments have been performed in which Lisp programmers were allowed to return “garbage” to the free-space list themselves. The results were disastrous: list structure thought to be garbage was returned to the free-space list even though the structure was still being used by other computations.

C, of course, accepts this “disaster” as a natural consequence of manual allocation management. It encapsulates the different attitudes of the two contemporary language communities, though: one wanting a machine in which to think (and willing to use computing power to simplify tasks), and those wanting raw performance from limited hardware (and willing to complicate the programming task to get it).

Overall, Allen’s book is a great attempt at an end-to-end discussion of Lisp all the way down to the metal. Many of the techniques are still relevant, at least as exemplars against later, more efficient, techniques should be judged.

(Thanks to Paul McJones for pointing me to the free PDF of the book, which he was responsible for developing. See this post for a history of how this came about.)

TIL: Web site carbon ratings

TIL: Web site carbon ratings

Today I learned about a site that rates web pages according to their carbon footprints.

My web site does well:

nil

I’m not all that surprised by this, since I use a static site generator and minimal (almost no) JavaScript: basically as low-power as one could get.

The full report includes an approximate carbon cost per page visit (60mg), and even tries to work out the underlying energy provision, dirty or renewable – dirty in my case at the moment, unfortunately. (I’m currently hosted on GitHub.) I should perhaps take the hint and move onto an alternative provider, or even host it myself with a solar-powered Raspberry Pi. Low-tech Magazine does this, but they are based in Barcelona rather than Scotland…

You can even include a badge that reports your rating “live”:

(It caches so as to only make one request per day.) On the other hand this increases the JavaScript footprint slightly, so I don’t think I’ll be using it anywhere apart from just here.