Programming pearls: literate programming

When was the last time you spent a pleasant evening in a comfortable chair, reading a good program? I don’t mean the slick subroutine you wrote last summer, nor even the big system you have to modify next week. I’m talking about cuddling up with a classic, and starting to read on page one. Sure, you may spend more time studying this elegant routine or worrying about that questionable decision, and everybody skims over a few parts they find boring. But let’s get back to the question: when was the last time you read an excellent program? Reading tells you where to find it. As a temporary substitute, this column introduces the programming style that Knuth used to create his program, and the WEB programming system that supports the approach. He calls the style “literate programming”; his goal is to produce programs that are works of literature. My dictionary defines literature as “writings having excellence of form or expression and expressing ideas of permanent or universal interest.” I think that Knuth has met his goal.