← all entries

Kruft and Code

November 12, 2026

There is a building at Harvard called Cruft, part of the old physics laboratory, which did radar work during the Second World War. The Jargon File, the hackers' dictionary kept since the 1970s, says under its entry for the word that "to this day (early 1993) the windows appear to be full of random techno-junk," and supposes that people from MIT or Lincoln Labs coined the term as a knock on the competition. Nobody has confirmed it. Guy Steele, who was a Harvard student and compiled the 1976 glossary, wrote that he didn't know. The Oxford dictionary gives the origin as unknown.

The story lasts because it gets the word right. Kruft, usually spelled with a c, is stuff seen through a window by someone walking past. To the passer-by it's junk on a sill. Inside the room it may be half of somebody's apparatus.

Code collects it the way a lab does. There's the branch for the one customer whose files arrive in the wrong encoding, a flag nobody has turned off since 2019, a retry that waits 340 milliseconds because 300 didn't work, a function called process2. Every programmer knows the feeling of opening a file and finding the sill.

And every programmer knows the remedy, which I'd put this way: there is no problem of kruft that cannot be solved by another layer of indirection.

Wheeler's jump

The line is bent from an older one. Butler Lampson, in his Turing Award lecture, credited David Wheeler of Cambridge with the saying that any problem in computer science can be solved by another level of indirection. Wheeler had the right to say it. Working on EDSAC around 1950, he devised the closed subroutine. Before that, a program that needed a square root contained the instructions for one, copied in wherever it was wanted. After, it contained a jump to the place where the square root was kept, and left behind a note of where to come back to.

That's what indirection means. The program stops holding the thing and holds a way of reaching it. Something now stands in between, and the something can decide what the name refers to today. A pointer does it. So do a file name, a URL, a driver, a virtual address and a function call. Most of what's called architecture is deciding where to put the in-between.

Applied to kruft, the move is familiar. Nobody rewrites the old billing module. They write a clean interface in front of it, and new code talks to the interface. The 340 milliseconds are still there. They've been moved behind something, and from the new side they can't be seen.

So the line is true, and the way it's true is the interesting part. The layer solves the problem of kruft by solving the problem of looking at it.

Six struts

A lower layer can look completely different in two views that know nothing of each other.

Take a hexapod, a platform carried on six struts that lengthen and shorten. The person writing a part program says to move ten millimetres in X. In that view the machine has an X, and X moved. Down at the drives there is no X anywhere. There are six motors, and for that one straight move all six ran, each a different distance, none of them in a line. LinuxCNC keeps the two vocabularies apart on purpose. Axes are positions in space and joints are the parts that actually move, with a kinematics module standing between. On an ordinary mill the two match one for one, and the documentation notes that the screens for such machines often hide the difference altogether.

Neither view is the real one. The machinist's X is no illusion, since the cutter did travel ten millimetres. The six motor positions are no deeper truth, either. They're what the same event looks like from the other side of the kinematics.

The same goes for a training sensor strapped to a racket. The player's view is one number, the speed of the racket head at contact. The firmware's view is a stream of gyro counts and a table of offsets measured for that one unit on a bench, because no two sensors come off the line alike. The table is the ugliest thing in the code and is the reason the number is right.

And that's where kruft lives. It isn't a property of the lower layer. It belongs to a view. The offset table is junk from the app and the whole job from the bench. The branch for the customer with the wrong encoding is clutter to whoever is reading the parser and is the entire account to whoever answers that customer's calls. Joel Spolsky made the point in 2000 about old code in general: the ugly lines are mostly bug fixes, each one a thing somebody learned the hard way, with the explanation gone missing.

Underbrush

It isn't only code. James C. Scott's Seeing Like a State (1998) opens in the forests of eighteenth-century Prussia and Saxony, where the state's foresters learned to see a forest as one figure, the yield of saleable timber. Everything else in the woods fell out of that view, including underbrush, deadfall, leaf litter and the trees nobody could sell. It was kruft, and they cleared it and planted single species in rows. The first rotation did very well. The second didn't, and German acquired a word for it, Waldsterben, forest death. The litter had been making the soil.

The foresters weren't fools. They had built a layer, and the layer worked. What they'd lost was the knowledge that there was another view of the same ground in which the junk was doing the work.

Unseeing

China Miéville's novel The City & the City (2009) is set in two cities that occupy the same streets. A citizen of Besźel walking down a road shares it with citizens of Ul Qoma, and has been trained from childhood to unsee them, their buildings and their cars. Each city is whole and consistent from the inside. To notice the other is a crime called breach, and a separate power exists to deal with it.

It's the best account I know of what living on top of a layer is like. The view holds because everybody inside it keeps it up, and nobody notices the keeping up. Spolsky's other well-known line, from 2002, is that all non-trivial abstractions leak to some degree. A leak is a breach. It's the afternoon the machinist's straight X move comes out slightly curved because one strut has backlash, and somebody has to stop unseeing the struts.

That is also the limit on the line this essay started from. The version usually told ends with a rider: any problem can be solved by another level of indirection, except the problem of too many levels of indirection. Each layer has to be kept up, and yesterday's clean interface is on today's sill.

The newest layer

A language model is the latest in-between, and the most accommodating so far. A person asks in plain words, and the model reads the old billing module so the person doesn't have to. As I argued in Fluid Frameworks, a good deal of what used to be frozen into code can now be assembled on request. Kruft is the other half of that. A model will put a fresh view over anything, and it will also tidy when asked, quickly and with confidence.

A layer that hides the 340 milliseconds costs little. A cleanup that deletes them, done from the one view in which they're junk, is the forester's mistake. So before clearing anything, it's worth asking the model what the code looks like from the other side, and who's standing there.

The windows at Cruft were full of something in 1993. From the street nobody could say what it was for. It'd be worth going in and asking before carting it off.


Sources: The Jargon File, "crufty" and "cruft"; Wikipedia, "Cruft"; Language Hat, "Cruft"; Butler Lampson, "Principles for Computer System Design," Turing Award lecture (1993), and Wikipedia, "Butler Lampson"; Maurice Wilkes, David Wheeler and Stanley Gill, The Preparation of Programs for an Electronic Digital Computer (1951); Diomidis Spinellis, "Another Level of Indirection," in Beautiful Code (2007); LinuxCNC documentation, "Kinematics"; Joel Spolsky, "Things You Should Never Do, Part I" (2000) and "The Law of Leaky Abstractions" (2002), Joel on Software; James C. Scott, Seeing Like a State (1998); China Miéville, The City & the City (2009).


A note on how this piece was written: the subject, the line about kruft and indirection, and the point that one lower layer can look entirely different in two independent views are mine. The examples, the research and the sentences were drafted by an AI model working from that direction. I'd rather say that plainly than have a reader guess at it.