6 works · 6 rooms
A first visit
Six works, one from each room, walked in the order the halls actually run.
There is no argument being made here beyond the obvious one: that these things are worth looking at slowly. Each stop is chosen because it is the clearest example of what its room is doing, and because it can be understood standing up. If you only ever take one tour, take this one, and then go back to whichever room made you want to stay.
Walking it takes you into the rooms, one work at a time. Everything below is the same tour, read here.
Hall of First Words
hello, world in CC · 1978
Four lines that almost every programmer has written, and nobody owns.
The Hall of First Words holds the same two words in seven languages, which sounds like a joke and turns into an argument. Put the C beside the Lua and the assembly and what you are comparing is not the program — the program is identical — but how much of the machine each language insists you acknowledge before it will say anything at all.
Start here because everything else in the building is, in some sense, a reaction to the problem of saying something simple.
Gallery of Patterns
SingletonTypeScript · 1994
The museum exhibits this one the way a museum exhibits an instrument of torture.
The Gallery of Patterns holds the classical forms, and this is the most famous of the twenty-three — and the only one its authors later publicly regretted. It is here because a collection that only showed the things it approved of would be a showroom.
Read the note before you judge the code. The code is not the problem; the code is fine. What is on trial is the idea that a program should have exactly one of something, forever, decided at the point of writing rather than the point of use.
Hall of Composition
AdapterTypeScript · 1994
The least glamorous thing in the building, and the one you have written most often.
You have crossed into the Hall of Composition, which holds six patterns about one object standing in front of another. This is the plainest of them: a small translator that exists only because you do not control both sides of a conversation.
It is worth stopping at precisely because it is boring. Most of what holds software together looks like this, and almost none of it gets written about.
Gallery of Methods
Binary SearchTypeScript · 1946
Twenty lines that defeated most of the profession, repeatedly, for decades.
The Gallery of Methods holds ideas that outlived the languages they were written in. This one is famous for a specific and humbling reason: Jon Bentley found that around nine in ten professional programmers could not write it correctly given unlimited time, and the version in Java's standard library carried an overflow bug for nine years before anyone noticed.
The algorithm is trivial. The invariant is not. That gap is the exhibit.
Hall of the Commons
What a Hundred Lines BecomesTypeScript · 2015
The file everyone pointed at in 2015, and what happened to it since.
The Hall of the Commons is the only room holding code the museum did not write — borrowed work, pinned to the commit it was taken from. This is state management entire, in about a hundred lines, and people reimplemented it in blog posts to prove the whole idea fitted in your head.
It is now 489 lines, roughly half of them comments. That is not decay. Read the note for what it is instead.
Cabinet of Curiosities
A Program That Writes ItselfJavaScript · 1960
A program whose only output is itself.
The Cabinet of Curiosities holds things code has no business doing. This one reads no input and opens no files — it cannot look at itself, so it has to contain a description of itself and then perform that description.
It is a good place to stop, because it is the one work in the museum that is purely about the pleasure of the thing. Nothing here is useful. That is the point of the room, and arguably of the building.
The other tours
- hello, world in seven languagesThe same twelve characters in C, Python, Lua, Rust, COBOL, x86-64 assembly and Brainfuck, walked in an order that turns the joke into an argument.
- What the book got rightSix patterns from 1994, thirty years on: which ones dissolved into the language, which became keywords, and which are still doing the work.