4 ms·
Literate programs sound fascinating. Is there somewhere I can read more? I've always thought self-documenting code was the way to go.
by mrfusion 12y ago
Literate programs sound fascinating. Is there somewhere I can read more?
I've always thought self-documenting code was the way to go.
- ekr 12y agoLiterate programming is a method introduced by Donald Knuth (http://en.wikipedia.org/wiki/Literate_programming http://en.wikipedia.org/wiki/Literate_programming). I've stumbled upon it whilst reading Physically Based Rendering, and then LCC: Retargetable C Compiler. There are some programs that can turn the "documentation" into code : http://en.wikipedia.org/wiki/WEB http://en.wikipedia.org/wiki/WEB , but most of them are quite old AFAIK.
- daly 12y agoBuy a copy of Physically Based Rendering (Pharr and Humphreys). It is a literate program that won an academy award. Make that your "gold standard" for good programming. Literate programs explain "why", not "what". Think of a literate program like a physics textbook. Your code is the equations but your explanations (not comments!) give the reader the reason WHY you wrote the code. See http://axiom-developer.org/axiom-website/litprog.html http://axiom-developer.org/axiom-website/litprog.html for an example of a trivial literate HTML program.