3 ms·
Ask HN: Was Donald Knuth completely wrong about good programming practice?
Nowadays, programmers are encouraged to write code with minimal comments — the exact opposite of Knuth's literate programming.
- jjgreen 4y agoLiterate 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.
- jstx1 4y ago> 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.
- bicijay 4y agoWhat a rude comment? Let the man ask his questions. Dont turn this into reddit with those snarky comments expecting "upvotes" please.
- 888666 4y agoI 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.
- whatwherewhy 4y agoI 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.
- pencilguin 4y agoI frequently encourage programmers to delete comments. Any comment that answers "what" instead of "why" is a problem solved by deletion.
- JoeMayoBot 4y agoProgramming 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.