Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What is the difference between literate programming and well documented programming?


Asked by Ali Macdonald on Dec 08, 2021 FAQ



This is the converse of literate programming: well-documented code or documentation extracted from code follows the structure of the code, with documentation embedded in the code; while in literate programming, code is embedded in documentation, with the code following the structure of the documentation.
Furthermore,
Literate programming is very often misunderstood to refer only to formatted documentation produced from a common file with both source code and comments – which is properly called documentation generation – or to voluminous commentaries included with code.
Keeping this in consideration, In literate programming the emphasis is reversed. Instead of writing code containing documentation, the literate programmer writes documentation containing code. No longer does the English commentary injected into a program have to be hidden in comment delimiters at the top of the file, or under procedure headings, or at the end of lines.
Indeed,
"Reduction of Visual Complexity" in Weaving a Program: Literate Programming in WEB, Van Nostrand Reinhold, 1989, pg. 42. The whole concept of code sections, indeed structured programming, is to reduce the amount of text that must be read in order to determine what a piece of code is doing.
In fact,
In 1986, Jon Bentley asked Knuth to demonstrate the concept of literate programming for his Programming Pearls column in the Communications of the ACM, by writing a program in WEB. Knuth sent him a program for a problem previously discussed in the column (that of sampling M random numbers in the range 1..