Part 4: First benchmarks

<- Part 3: Building the benchmark harness [Part 5: More benchmarks] (Not yet published) ->
   

Now that we have a harness to systematically capture our results for later analysis, we can begin comparing the performance of an implementation of TeX’s data structures in the original, 1980’s C style, with that of an implementation in modern C++ style. It turns out that even casually-designed benchmarks can contribute useful results.

more ...

Tex Cut

Why do we now isolate into levels? Knuth, working alone, was justified to implement a feature across as many levels as he wished. In fact, the TeX code doesn’t really have levels in the strict sense. (See Notes 1 and 4 above.) But modern software design would establish those levels in design and enforce them syntactically. This makes more sense (essential?) for multi-person teams.

more ...

Part 3: Building the benchmark harness

<- Part 2: Reimplementing the TeX data structures in C++ Part 4: Running the benchmarks -> (Not yet published)
   

Benchmarks purport to give generalizable results. We don’t really care that one specific run, of a specific program, on a specific machine configuration, took a specified time. We care what that might indicate more generally. For a benchmark to provide useful generalizations, its conditions must be accurately recorded.

In my experience, recording the run conditions is surprisingly difficult. Just recording the timing results isn’t informative. What optimization level did I compile the program with? And was every file compiled with the same level? Which version of the code produced that output?

more ...

Part 2: Reimplementing the TeX data structures in C++

<- Part 1: Reading TeX: The Program in 2026 Part 3: A Benchmark Harness ->
   

While reading the TeX source code (see Part 1), I repeatedly asked myself, “What if we implemented the data structures using modern tools? Would the design be clearer? Would it perform better?”. Knuth took enormous pains to save memory. He also designed TeX’s dynamic memory allocator to be compatible with the early virtual memory systems of the 1980s. While he did his best, the resulting code is obscure compared to how we would implement this design using modern language facilities.

more ...

Reading "TeX: The Program" in 2026

[Start of series] Part 2: Reimplementing the TeX data structures in C++ ->
   

According to the order slip tucked into my copy, I ordered TeX: The Program on June 5, 1986. For four decades as I moved through two countries and nine mailing addresses, that book lived in boxes and bookshelves. I took it out several times, intending to read it, each time setting it aside because I wanted to understand TeX’s syntax first. So I took down its companion volume, The TeXbook, read a few chapters in, set that aside and never returned to either one.

more ...