--- layout: ../Site.layout.js --- # Planning an elephantine kitten with common lisp object system's metaobject protocol Handwriting is not quite good enough to create a [kitten](https://kitten.small-web.org/tutorials/components-and-fragments/). I remember this from *C. Sidney Burrus* on the *fastest fourier transform in the west*: > A human cannot meaningfully handwrite a discrete fourier transform program. However, a human can write a program that can write a discrete fast fourier program. This is a general principle of scientific programming. I will find the citation for that later, but that is how I remember the line. A human can look up the equations and literally write in whatever programming language the equivalent statements to a Winograd fourier transform, but this is not what we usually mean when we say we want to do a fast fourier transform. The amount of handwriting to do per single use is simply too high. Nor can I write a simple macro. We need a static program analysis that runs as part of compilation that chooses what program to write, writes it, and *that* gets compiled. As you know, [*cl-series*](https://gitlab.common-lisp.net/rtoy/cl-series/\-/wikis/Series-User's-Guide) is my favourite example of this. LLM generated code is known to never be possible as a replacement, because the static program analysis we are talking about must be rigorous. Similar to how an LLM cannot possibly do cryptography - that technology simply cannot do that. ### Note, *Des Rivières* home page and obit. and spelling from [amszmidt](https://tumbleweed.nu/) Thanks for clarifying the spelling of *Des Rivières*, and I suggest anyone reading this [go read that instead](https://www.arbormemorial.ca/en/capital/obituaries/james-des-rivi%C3%A8res/33255.html) (as well! Come back here after the art of the metaobject protocol). Jim des Rivières home page continues: [MOTH IMAGES](https://ottawa.moths.ca/). ## Handwriting a kitten once There are, I think, a lot of professional web programmers whose jobs are to handwrite good single websites for single customers some of whom have asked me why I do not just hand-write one kitten once. The implication is that the single website receives visitors constantly for a long time into the future, so a large up-front effort in handwriting this single site inevitably pays off. I think they are right that a lot of websites (literally, their customers') are like this. ## Lisp and solving a space of problems [The Art Of The Metaobject Protocol (Kiczales, Des Rivières and Bobrow)](https://ldbeth.sdf.org/The_Art_of_the_Metaobject_Protocol.pdf) gives the goal for lisp's metaobject protocol like this: > Instead of the common lisp object system satisfying a single point in the space of possible object systems, the metaobject protocol fills *an area* of possible object systems. Well, I will check "what it actually says" later and add a note if necessary. It points out that people who genuinely liked Flavors more than CLOS can simply MOP (use the metaobject protocol) the object system into literally doing what (mid-period Lisp machine generics) Flavors did. This is a similar point to the *fastest fourier transform in the west* program generating programs for a space of possible fast fourier transform desires, in making a metaobject protocol for a space of possible object system desires. In this lisp and broader programming tradition, I want to fill an entire space with kittens, not just have one kitten once. # Implementation goals I rhetorically pigeon-holed myself into using [the mop](https://closer.common-lisp.dev/) here. I recall my friends and mentors on the Mastodon were extolling the book recently. It was a long time since I last tangled with AMOP - at the time there was lots of ANSI CL I did not know enough about to appreciate where the MOP was coming from. In terms of related examples, upto 2008, common lisp [elephant](https://common-lisp.net/project/elephant) used the MOP to define lisp `standard-class` as being backed by the ACID berkeley-db. # Forward I'm going to reread the Art of the Metaobject Protocol before calling anything else. While it seems like I could use CLOS shared allocation slots and specialize method-qualified after `shared-initialize` to wire up a class that is a straightforward persisted, maybe automatically updated kitten, I think MOPing as we just said is a stronger approach for these reasons: - A subset of the running lisp application database and kitten application database should be strongly consistent - A kitten metaclass should literally be the XDG directory content of that kitten - The kitten `page` metaclass should literally be the files in their kitten parent In my opinion it is better for these to be literal truths about their metaclass than for this to be made-true by use of generics to syncronise manually in either direction, similar to how elephant changed `standard-class`. # Fin Thoughts, opinions, criticisms, bids of good luck sought [on the mastodon thread](https://gamerplus.org/@screwlisp/114685251387620164).