logoalt Hacker News

zerrtoday at 1:19 PM4 repliesview on HN

The valuable prose aside, I never liked that code examples were in a pseudo assembly language.


Replies

jll29today at 4:19 PM

I agree with that opinion. He started writing TAOCP in 1968, and could have switched to Pascal in 1972.

Pascal is simple and clear, and can be translated easily to anything from LISP, Fortran, Python to C or C++ (in fact, subsets of Pascal are often used as sample language in books about compilers, including in Pascal inventor N. Wirth's own compiler book (which, unlike Knuth's, was completed timely):

Wirth, Niklaus, Compilers (1996), 101pp., 2rd revision, 2017, online: https://people.inf.ethz.ch/wirth/CompilerConstruction/Compil..., last accessed 2026-07-07).

It does not matter that Pascal is not much in use anymore, because due to its readability, it's timeless. It nearly reads like English prose, yet is automatically executable. It has also been standardized, and there is a book-sized language description available, as are several -- commercial and open source -- implementations.

In contrast, his pseudo-assembler is arcane. Whenever I wanted to implement an algorithm following Knuth TACOP, I had to work off his English pseudo-code description rather than the associated pseudo-assembler code.

commandlinefantoday at 1:31 PM

There are M/MIX assemblers and interpreters you can download and run - in some ways they're better than "real" programming languages because they're explicitly for instruction so usability concerns like package managers and build automation support don't get in "the way" of operating them.

mghackerladytoday at 1:38 PM

It's the only thing he could've done if he wanted the books to stand the test of time

convolvatrontoday at 1:34 PM

consider the alternatives. it could have been written in PL-1 and rapidly become dated. or it could have been written in a slightly higher level custom language and that would also have to be taught and would be less clear about what was going on under the hood. or a kind of pseudo-code that would also admit ambiguity. or it could have been rewritten in pascal, and then java, and then javascript and then rust.

given the timespan and the focus on complete analysis of running times and not just asymptotics, in the end maybe it wasn't so terrible a choice.

show 1 reply