Ask HN: Was Donald Knuth completely wrong about good programming practice?

5 points by amichail ↗ HN
Nowadays, programmers are encouraged to write code with minimal comments — the exact opposite of Knuth's literate programming.

7 comments

[ 5.3 ms ] story [ 26.3 ms ] thread
> Nowadays, programmers are encouraged to write code with minimal comments

No, they aren't. Find a better hobby than asking absurd questions several times a day.

What a rude comment? Let the man ask his questions. Dont turn this into reddit with those snarky comments expecting "upvotes" please.
I don't believe I comment excessively, but in code reviews I've only ever been told to remove comments rather than to add more while working as a software engineer.
I write programs cca 2:1 comments:code and it is consistently praised for its readability during code reviews and by later maintainers that have to add features to it.
I frequently encourage programmers to delete comments. Any comment that answers "what" instead of "why" is a problem solved by deletion.
Literate programming is not really comments, rather documentation and code combined. Whether that's a good idea is another question, it never really caught on. But when you have TeX and TAOCP in your back pocket, a couple of flops is no great shakes.
Programming practices vary over time and depend on the preferences of those writing the code. There are some, myself included, who believe the naming conventions and organization of the code should be meaningful to make it easier for other developers to read the code. Typically, if code is complex, a comment might be justified, though it often indicates that the code needs to be simplified. Typically, if I write a comment, it will mostly be something along the lines of why we took this approach or any dependencies that aren't obvious. That said, documentation comments (e.g. classes and methods) are useful for automated tools that help developers see API specs or automated swagger/openid UIs.