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.

Diary of an MP’s Wife: Inside and Outside Power

Sasha Swire

An insight into the British politics of the 2010s. And not a pretty sight.

The pitch for this book is that, as a political wife, the author had a unique ringside seat from which to observe the goings-on the (mostly male) politicians. And it’s true that she has plenty of insight into them and into her own position in the circle.

But she also exposes herself as almost a caricature of a Tory. She accepts the misogyny and crudeness of the male MPs as just how it is, and utterly lacks any understanding of why anyone would disagree with her own positions. She can’t accept, for example, that Remainers were sincere and their misgivings might be valid, or that the EU is anything other that fascinated with the idea of humiliating Britain. She constantly refers to the Labour party as “Marxists” and trots-out the usual tropes of how they would bankrupt the country, despite the fact that their “extreme left-wing” positions would be entirely mainstream in many European countries. She’s clear-eyed and unenthusiastic about Boris Johnson as Prime Minister, but then fawns over him when he wins his election landslide and glides over the time-bomb he planted on the Irish border issue, even though this was evident at the time.

The overwhelming theme, returned to again and again, is how self-interested the political class is, focused entirely on who’s up, who’s down, and how if affects their own careers. Lots of dinner parties, gentlemen’s clubs, and holidays: one is left amazed by how shallow everyone is.

It’s not a bad book, and an enjoyably light read. But politically insightful it isn’t, other than to highlight the trivial nature of politicians.

Merged review:

An insight into the British politics of the 2010s. And not a pretty sight.

The pitch for this book is that, as a political wife, the author had a unique ringside seat from which to observe the goings-on the (mostly male) politicians. And it’s true that she has plenty of insight into them and into her own position in the circle.

But she also exposes herself as almost a caricature of a Tory. She accepts the misogyny and crudeness of the male MPs as just how it is, and utterly lacks any understanding of why anyone would disagree with her own positions. She can’t accept, for example, that Remainers were sincere and their misgivings might be valid, or that the EU is anything other that fascinated with the idea of humiliating Britain. She constantly refers to the Labour party as “Marxists” and trots-out the usual tropes of how they would bankrupt the country, despite the fact that their “extreme left-wing” positions would be entirely mainstream in many European countries. She’s clear-eyed and unenthusiastic about Boris Johnson as Prime Minister, but then fawns over him when he wins his election landslide and glides over the time-bomb he planted on the Irish border issue, even though this was evident at the time.

The overwhelming theme, returned to again and again, is how self-interested the political class is, focused entirely on who’s up, who’s down, and how if affects their own careers. Lots of dinner parties, gentlemen’s clubs, and holidays: one is left amazed by how shallow everyone is.

It’s not a bad book, and an enjoyably light read. But politically insightful it isn’t, other than to highlight the trivial nature of politicians.

3/5. Finished Friday 23 February, 2024.

(Originally published on Goodreads.)