06 — NOTES N·04

BACK TO THE NOTES

N·04 ESSAY

The partsnobodysees

The inside of a thing is also a surface. Someone will open it — and the someone is usually you, a year later, at night.

The red and the grey wall, with photographs on them.
The underside of a drawer turned over: dovetails and a maker’s pencil mark.

Take the back off a well-made instrument and something happens that no advertisement for it ever mentions: you keep looking. The cables are dressed in one direction. The screws all turn the same way. Somebody decided where each part would sit, and then decided again, for no audience at all.

This page is built on that decision. Under the black hole, the motto and the forme there is an engine — I call it the Kernel — and almost nobody who visits will ever read a line of it. That is exactly why it has to be written as carefully as the parts they do see.1

An audience of one

The usual argument for clean internals is economic: code that is easy to read is cheap to change. It is true, and it is not why I care. I care because the inside of a thing is also a surface. Someone will open it. Usually the someone is me, a year later, at night, trying to remember why a number is 0.86 and not 0.9.

A cabinetmaker who planes the back of a drawer as smooth as its front is not being sentimental. They are making the drawer for the person who will one day pull it all the way out. A codebase has that person too, and it has them far more often than a drawer does.

Nobody sees the inside. That is not the same as nobody being there.

One loop, five phases

The clearest example is time. A page like this one moves dozens of things at once — the object, the type falling into it, the cursor, the field of the ruling, sound — and each of them wants to read the screen and write to it. Left alone, they interleave: one reads a box, another changes it, the first reads it again, and the browser lays the page out three times in one frame.

So there is exactly one requestAnimationFrame in the whole application, and every piece of work joins it in one of five phases that always run in the same order:

export const PHASES = ['input', 'simulate', 'read', 'write', 'render'] as const;  // A consumer never reads a value its producer has not yet written: clock.on('read', () => { 	const at = scroll.position;      // arithmetic on what was measured 	if (at !== last) outline.move(at); // no layout read while the page moves }); 
The order a frame is made in. Measuring happens in read; nothing measures in write.

Nobody visiting the page sees five phases. What they see is a page that does not stutter when they scroll it, on a phone that cost a fifth of a laptop. The order is invisible; its consequence is not.

The sheet with DETAIL pressed: the ruling every word is set on, the record, the entry and the key.
FIG. 01 The sheet read closely: DETAIL draws the ruling every word on it already stood on. The ruling was always there; the key only shows it.

Names are the first interface

Before any of it runs, it is read — and what is read first is names. A name that drifts is a second name for the same thing, and a second name is half the results of every search, forever. So the project keeps a few rules that look fussy until the day they save an hour:

  • One word for one thing, everywhere: in the code, the comments, the documents and the commit messages.
  • One spelling, checked by a tool rather than by taste — and the tool runs before every commit.
  • A name says what a thing is, not how it was built: world, not themeController.
  • A comment says why. The code already says what.

None of this is visible on the page. All of it is visible in how fast the next change is made.

Instruments lie quietly

The hardest internals to keep honest are the ones that measure. Every instrument this project has used has, at least once, reported a number that was better than the truth — never worse, which is what makes it dangerous.

  1. A size budget that, after a failed build, quietly measured the previous one.
  2. A GPU timer whose readings, on one phone’s tiled renderer, were off by a factor of forty.
  3. A fence that was polled from a scheduler, and so timed the main thread instead of the GPU.
  4. A still page that cost sixty style recalculations a second, because one small animation was written in percentages.

Each of those was found the same way: by refusing to believe a good number until a second instrument, built differently, agreed with it.2

Section 05’s practice: a square bed of type leaning toward the reader, one tool lifted out of it with the tools it is worked with.
FIG. 02 The practice, in relief. Each tool is a sort in a bed; under a pointer it lifts, and lifts what is worked with it.

Opened, a year later

I do not think care for the inside makes the outside better automatically. I think it makes the outside possible to keep. A beautiful page whose internals are a mess is beautiful exactly once: the first change breaks something nobody can find, and the second change is made to avoid finding it.

Engineering and art should be seen through the same lens.

— The motto this site is built on

The motto at the top of this site is usually read as a sentence about the surface. It is just as much a sentence about the back of the drawer.

NOTES

  1. 1 The Kernel is src/lib/engine/ in this site’s repository: a frame loop, motion, scroll, input, sound, a game’s machinery, and, since this note, reading. None of it knows what site it is running. Back to the line
  2. 2 The rule, written down after the second time: a measurement that could fail into a flattering number needs a control that cannot. Back to the line

RESPONSES

No responses yet.

Write in the margin

The margin is written in under a name: sign in to write in it, or register — it takes a minute.