Literate programming¶
The idea of ‘literate programming’ was invented by Donald Knuth. The concept is quite simple—the decriptions that accompany code should be informative and progress from beginning to end with logical and clearly written text. This is in contrast from the more conventional style of terse commenting used in software development. Another important part of literate programming is that the code embedded within the text should be easily run by the reader, which necessitates the use of working examples.
Literate programming does not have to be restricted to developers. A driving force behind the creation of lpEdit was so that researchers of many backgrounds could incorportate literate programming into their scientific lives.
This is a document. And the goal is to be able to embed code that is run when the document is created. For example if I cannot remember how do write a recursive function.
for-example
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
print(factorial(10))
...
3628800
We can be sure the function works because an error would not allow the document to be made.
Notable Software¶
- Python object-oriented scripting language
- Pweave Sweave package for Python
- PyLit package for literate programming in Python using reStructuredText
- pyreport Another package for literate programming in Python
- R software for statistical computing
- Sweave the Sweave package
- Ruby another object-oriented language
- Rubyweb A web-oriented literate programming system
- Sphinx works with Python, C/C++, Ruby, JS and others