Programs To Read

This is a list of programs/collections of code worth reading. Some are GreatProgramsToRead and some are not. What they should have in common is some educational merit. One should benefit from having read the programs listed here.

Anent the "exceptionally unbuggy" assessment: for over 13 years, Knuth kept a log of all the errors he found (or received reports of) in TeX, with notes as to how he fixed them. (He may still be keeping the log for all I know, but it had over 13 years of entries in it when it was published in 1991.) I can only say that I wish I had as short a bug list in some of my major systems after even just 5 years. Naturally, Knuth attributes his low rate of errors to his use of LiterateProgramming techniques. He published a paper, "The Errors of TeX", on this subject in 1989.

(It would be helpful if people adding items to this list would include some commentary explaining what makes the programs worth reading, and to whom.)

And why the choice of Pascal is unfortunate, or is that bit just flame bait?

You're free to disagree, but there's more than just flame bait to this comment. See BrianKernighan's article WhyPascalIsNotMyFavoriteProgrammingLanguage for some cogent objections to Pascal -- at least, the dialect of Pascal that was available when Knuth was writing TeX. Many of Kernighan's objections, which were derived from his experience porting his book Software Tools from Ratfor to Pascal, are (not coincidentally) also things for which Knuth felt it necessary to provide workarounds in Web, the LiterateProgramming system he invented specifically for the implementation of TeX and Metafont. Knuth and Levy's later tool, CWeb, which is based on C an C++ rather than Pascal, omits certain features of the Pascal-based Web precisely because C, a more expressive and powerful language, doesn't need them.

See also LiterateProgramming