“Documentation is an often overlooked aspect of data science. It’s commonly left until the end of a project, but then you’re excited to move on to a new project, and the documentation is rushed or omitted completely. However, … documentation is a crucial part of making your code reproducible. If you want other people to use your code, or if you want to come back to your code in the future, it needs good documentation. It’s impossible to remember all your thoughts from when you originally wrote the code or initially carried out the experiments, so they need to be recorded.” (Nelson 2024)
Types of documentation
“Names: Names of variables, functions, and files should be informative, an appropriate length, and easy to read.
Comments: Your comments should add extra information not contained in the code, such as a summary or a caveat.
Docstrings: Your functions should always have a docstring that describes the inputs and outputs of the function, as well as the purpose of that function.
READMEs: Every repository or project should have an introduction that advertises your code and lets other people know why they should use it.
Experiment tracking: Experiments, especially in machine learning projects, should be tracked in a structured way.”
Jupyter notebooks: Your notebooks will be much easier to read if you give them good names, give them a structure, and intersperse text and code.
Google Ngram plot for literate programming (1984+, 5y smoothed)
Google Ngram: "literate programming"
Decade patterns (1984–2019), per-billion tokens
Decade
Trend (yearly)
Mean
Max
Max year
Years
1980s
0.095
0.357
1989
6
1990s
0.320
0.659
1998
10
2000s
0.268
0.594
2000
10
2010s
0.216
0.970
2019
10
Google Ngram table for literate programming (1984+, 5y smoothed)
IPyLeaflet map of Cambridge, UK
A brief history of literate programming
The original WEB system was designed as a “tool for systems programmers, not for high school students or hobbyists”, because the programmer needs to be “comfortable dealing with multiple languages simultaneously” (Knuth 1984).
Jupyter notebooks
“Notebooks — documents integrating prose, code and results — offer a way to publish a computational method which can be readily read and replicated.”
“Prose text can be interleaved with the code and output in a notebook to explain and highlight specific parts, forming a rich computational narrative.”
Pimentel et al. (2019) analysed 1.4 million notebooks on GitHub and found that out of 863,878 attempted executions of valid notebooks (i.e., notebooks with defined Python version and execution order):
Only 24.11% executed without errors
Only 4.03% produced the same results
They make recommendations for improving the use of Jupyter notebooks.
Nelson recommends using Jupyter notebooks for development work, before refactoring notebooks into modularised Python scripts with accompanying tests (Nelson 2024).
---
title: "In Praise of Documentation: Tools, Tips & Techniques for Literate Programming in the AI Age"
date: "2026-03-01"
categories: [documentation, talks]
format:
html:
toc: true
code-fold: true
jupyter: pydata
bibliography: refs.bib
---
To render a Quarto document, use quarto render on the command line.
Computer programs as literature
Computer programs as literature
“I believe that the time is ripe for significantly better documentation of programs, and that we can best achieve this by considering programs to be works of literature” Knuth (1984)
Computer programs as literature
“Let us change our traditional attitude to the construction of progams. Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do” Knuth (1984)
Computer programs as literature
“The practitioner of literate programming can be regarded as an essayist, whose main concern is with exposition and excellence of style. Such an author, with thesaurus in hand, chooses the names of variables carefully and explains what each variable means. He or she strives for a program that is comprehensible because its concepts have been introduced in an order that is best for human understanding, using a mixture of formal and informal methods that reinforce each other” Knuth (1984)
George Orwell (Orwell 1945) considered good writing to be active, precise, and simple.
He argued we should write actively rather than passively, be precise rather than vague, and use simple verbs rather than complex longer words or phrases.
If we can drop a word from a sentence without losing the meaning, we should drop it.
Rules for good writing
George Orwell at the BBC in 1940
Orwell called the use of language a habit. And he made a close relationship between language and thought.
By learning to write well, we can develop good ways of thinking. By writing clearly, we can think clearly, and thereby communicate our thoughts more clearly to others.
The thoughts are in the words, and our thinking is displayed in our writing, so we had better choose our words wisely.
In writing well, we can feel more like a human being, rather than a machine.
Read the Docs: free hosting that builds and publishes documentation from your repository.
Sphinx: extensible documentation generator (reStructuredText-first) used widely in Python for multi-format technical docs.
tldr: concise, community-driven, open-source help pages for command-line tools.
Write the Docs: best practices for creating software documentation and technical writing.
Zensical: static site generator for Markdown documentation sites, from the same ecosystem as Material for MkDocs.
References
Gazzard, A. 2016. Now the Chips Are down: The BBC Micro. The MIT Press.
Kluyver, T., B. Ragan-Kelley, F. Pérez, B. Granger, M. Bussonnier, J. Frederic, K. Kelley, et al. 2016. “Jupyter Notebooks – a Publication Format for Reproducible Computational Workflows.” In Positioning and Power in Academic Publishing: Players, Agents and Agendas, edited by F. Loizides and B. Schmidt.
Nelson, C. 2024. Software Engineering for Data Scientists: From Notebooks to Scalable Systems. O’Reilly.
Orwell, G. 1945. Politics and the English Language. London: Penguin Books.
Pimentel, J. F., L. Murta, V. Braganholo, and J. Friere. 2019. “A Large-Scale Study about Quality and Reproducibility of Jupyter Notebooks.” In IEEE/ACM 16th International Conference on Mining Software Repositories, 507–17. Montreal, QC, Canada. https://doi.org/10.1109/MSR.2019.00077.