←back to thread

88 points joecobb | 5 comments | | HN request time: 0s | source
Show context
em500 ◴[] No.46180399[source]
This essay seems to be missing the main primary references for literate programming:

https://www.cs.tufts.edu/~nr/cs257/archive/literate-programm...

https://www-cs-faculty.stanford.edu/~knuth/lp.html

Knuths intention seems clear enough in his own writing:

Literate programming is a methodology that combines a programming language with a documentation language, thereby making programs more robust, more portable, more easily maintained, and arguably more fun to write than programs that are written only in a high-level language. The main idea is to treat a program as a piece of literature, addressed to human beings rather than to a computer.

and

Let us change our traditional attitude to the construction of programs: 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.

replies(5): >>46181093 #>>46181151 #>>46181215 #>>46184360 #>>46185842 #
1. d-lisp ◴[] No.46181093[source]
I dream of a world where the Knuth idea of programming and mathematics are naturally embedded in our cultures, like novels are.

I find it weird to not be able to find linux source code and commentaries or even math/physics/science masterpieces in libraries where you can find Finnegan's Wake easily (at least where do I live), and not be able to talk about the GHC in between two discussion about romance or the weather at the bakery.

replies(1): >>46182902 #
2. Nevermark ◴[] No.46182902[source]
> I find it weird to not be able to find linux source code and commentaries

That one statement is a great concise explanation/motivation for "literate programming".

Explanations with code, that explain code design choices, in a way that enables the code to be understood better, and the ideas involved to be picked up and applied flexibly to reading and writing other code.

Another way to view it is: Developers are "compilers" from ideas to source. Documenting the ideas along with the "generated" source, is being "open source" about the origin and specific implementation of the source.

replies(2): >>46184942 #>>46187122 #
3. 1718627440 ◴[] No.46184942[source]
This is how I see version control. Adding another dimension to every line of code, that explains the why that code is that way it is.
4. MrJohz ◴[] No.46187122[source]
I think that statement is also a great concise explanation for why literate programming doesn't really work in practice.

For something as complex as the Linux kernel, there is no single document that is going to explain the entire system to anyone who reads it. For a start, different people need different levels of explanation. Someone fresh out of a JavaScript bootcamp is going to need a very different guide to Linux than someone who's spent years working on the Windows kernel and just needs to know what's different and what's the same. Moreover, the further a person is from understanding how the Linux kernel works, the more iterative the explanation will need to be: first setting up the broad concepts, then explaining these concepts in more detail, then clarifying these details with more precise examples, and so on. If these layers of explanations are bound to code, then the person who needs less of an explanation will end up skipping parts of the codebase (assuming they let themselves be guided by the literate documentation). If the explanation is not bound to the code, then that's not really literate programming, it's just documentation.

The other issue is that even two different people with similar levels of skill will often want things explained in different ways. Partly, that's going to be things like the analogies they're used to, and partly that's going to be a question of what they need from the explanation. A document "The Linux Kernel for the Data Scientist" will probably look very different from "The Linux Kernel for the Systems Engineer", and both will be different again to "The Linux Kernel for Project Managers". A huge part of technical writing is understanding precisely who your audience is, and in literate programming, your audience kind of becomes "everyone", which is too large an audience. The advantage of separating code and documentation is that you can write your code for a much more restricted set of readers, but provide a bunch of different additional guides that are each aimed more precisely at a target audience.

I think literate programming can work for programs that are primarily intended as tools for teaching (because then the whole application is designed to be read by a specific target audience, and can be written from that perspective), but for general-purpose applications, particularly more complex ones like the Linux kernel, are better served by separating out the different documentation concerns.

replies(1): >>46199524 #
5. d-lisp ◴[] No.46199524{3}[source]
"Linux Kernel for the self-conscious lifeforms" would definitely fit on my shelves .