Remix.run Logo
em500 21 hours ago

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.

zahlman 18 hours ago | parent | next [-]

> I chose the name WEB partly because it was one of the few three-letter words of English that hadn’t already been applied to computers.

Heh.

bombcar 5 hours ago | parent [-]

The earth if it was World Wide WEB …

rhdunn 18 hours ago | parent | prev | next [-]

In a way this is what notebooks are for Python and other languages. They mix documentation and code such that you can run that code and inspect the output. See for example the pytorch tutorials.

d-lisp 17 hours ago | parent | next [-]

Yes, notebooks are a restrictive type of litterate programming, interactive and browser bound.

TeX was "proven" as a text/typography tool by the fact that the source code written in WEB (interleaving pascal and TeX (this is meta (metacircular))) allows for you to "render" the program as a typographed work explaining how TeX is made+ run the program as a mean to create typographic work.

I'm lacking the words for a better explanation of how do I feel sbout the distinction, but in a sense I would say that notebooks are litterate scrips, while TeX is a litterate program ? (The difference is aesthetical)

d0mine 16 hours ago | parent [-]

There is Org Babel in Emacs that can be an alternative to jupyter notebooks for literate programming (research/devopsy tasks). It is more powerful in some aspects and weaker in others.

electroglyph 18 hours ago | parent | prev [-]

or all the unsloth notebooks

d-lisp 18 hours ago | parent | prev | next [-]

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.

Nevermark 14 hours ago | parent [-]

> 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.

MrJohz 5 hours ago | parent | next [-]

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.

1718627440 10 hours ago | parent | prev [-]

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.

11 hours ago | parent | prev | next [-]
[deleted]
smusamashah 8 hours ago | parent | prev [-]

If a program has very detailed comments will it fall under literate programming pattern?