11 ms·
Yeah, the word "read" seems to have seduced us into an obviously false analogy. "Reading" code is not like "reading" a novel. Perhaps this could seem more pla
by emodendroket 5y ago
Yeah, the word "read" seems to have seduced us into an obviously false analogy. "Reading" code is not like "reading" a novel. Perhaps this could seem more plausible if your work was primarily along the lines of Knuth's, rather than combining the same bag of shopworn, well-known techniques into academically rather uninteresting production code.
Another article on this topic I recommend is "Code Is Not Literature," from Peter Siebel: https://gigamonkeys.com/code-reading/ https://gigamonkeys.com/code-reading/
- copperx 5y agoCode as it is written today is not literature, but Knuth's idea was to make it readable like literature, because you would be mostly reading words, formulas, and algorithm descriptions, and code itself would be an incidental detail. Peter Siebel is right. However, he is talking about code as it is written today.
- emodendroket 5y agoRight, but my contention here is that not achievable for reasons Siebel describes: a real program ends up having to have a bunch of stuff extraneous to the main idea most of the time.
- rob74 5y agoYeah, usually "reading code" doesn't mean reading a file from beginning to end, just reading (and, more importantly, understanding) the parts that you need to understand in order to fix a bug or implement a new feature. And "readability" also includes being able to easily find the places you need to "read" and then change.
- TheOtherHobbes 5y agoI think Knuth is just plain wrong - documentation and code should be separate things with different aims and requirements. It's one thing to include some background notes around a single algorithm, it's something else entirely to document an entire application. The missing link is the lack of meta-representation and abstraction tools. Text is very poor way to show relationships, and most code is more like a tree structure. IDEs have gotten better at representing this, but they still tend to show text files as primary and relationships as secondary. More text in/around the text files is definitely not the answer. Structural representations - dynamic useful ones, not bureaucratic nonsense like UML - and smarter searching and filtering are more likely to be helpful, with associated text descriptions for key concepts.
- emodendroket 5y agoI think you’re right, especially when you look at the kind of silliness he’s actually writing. It’s just overcommented code, and worse than that, trying to be cute. Sorry, massive respect for the guy and his accomplishments, but this is not a good idea.
- wudangmonk 5y agoI don't get the association between reading and literature. Math books can be read, are there Math book reading clubs? now take away all the context and just leave the equations, that would be code. I don't known about others but I need to actually do the math to understand a math book and those always include the context.
- emodendroket 5y agoI’d say the notion of “curling up with a book” strongly evokes literature. And calling it “literate” programming invites the comparison as well. But a program isn’t like a math book either. It is actually pretty rare to actually just read a program start to finish.
- couchand 5y agoI would suggest it's just as rare to read a math book from start to finish...
- emodendroket 5y agoMaybe so, but the progression and unit size are closer to narrative books than to code.
- wudangmonk 5y agoI understand what Knuth means by literate programming and I personally like doing it for some pieces of my code so that a few months later I understand what I was thinking at the time and either continue or change things because I now know better. The same way one might write their mind in a journal and cringe at the content years later. Seibel seems to have taken the literate part of literate-programming too literately with his reading club and not expecting to implement at least a toy version of the code to understand it. This is why I compared it to a math book, in that it is also a book that is read but to really understand something one must work out some of the problems. I did not mean that a program is like a math book, I meant that a literate-program is like a math book because it adds some context to the math inside. I think a program itself is like math with no context where you have to reverse engineer what its doing by guessing what the person who wrote it was trying to do.
- cxr 5y agoThe author of this post has another on that topic: "Nobody's just reading your code" <http://akkartik.name/post/comprehension http://akkartik.name/post/comprehension>
- cafard 5y agoA most interesting article, thank you.