graph TD A[Start feature or analysis] --> B[Explore & experiment] B --> C[Write code] C --> D[Write & update documentation] D --> E[Review & refactor] E --> F[Share / deploy] F --> B
How I learned to love documentation
The perils of poor documentation
Why document your code
Types of documentation
Literate programming
Scientific publishing tools
Computer programs as literature
Documentation in the age of AI
This presentation was made with ❤️ using Quarto, Python, and deployed with GitHub Actions.
“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)
“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.
Nelson (2024)
graph TD A[Start feature or analysis] --> B[Explore & experiment] B --> C[Write code] C --> D[Write & update documentation] D --> E[Review & refactor] E --> F[Share / deploy] F --> B
A document formatting language
A programming language
Knuth (1984)
WEB system:
A document formatting language (TeX)
A programming language (PASCAL)
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).
| 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
“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 and only 4.03% produced the same results.”
They make eight recommendations for improving the use of Jupyter notebooks.
Marimo 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
---
You render the Quarto document with quarto render talk.qmd on the command line.
“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”
“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”.
“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.
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.
Coding agent CLI or IDE tools can be instructed to read the AGENTS.md and do “spec-driven development” (e.g. Cursor, OpenAI Codex, Claude Code).
Feel like a human being, rather than a machine
Feel good about ourselves, be appreciated by others, whilst also making the world a (slightly) better place
Preserve institutional and personal memory
Ensure scientific reproducibility
Allow better version control, so software is robust
Enable responsible stewardship of technical systems, to allow future maintenance
Documentation can be technically “fun”
To read a longer version of this talk, visit the blog @ carecodeconnect.io
Diátaxis: documentation framework
Write the Docs: best practices for creating software documentation and technical writing.