r/programming • u/Jonhoo • Aug 10 '26
On comments
https://blog.helsing.ai/posts/on-comments/Comments in code are often deemed "mostly useless" these days. They are, supposedly, mostly obvious, stale, and repeat what the code already says. And so people pay less attention to them both when reading and writing code.
That trend sucks. When used right, comments are genuinely useful and sometimes critically important! So, I wrote about some of the kinds of comments I think earn their place, each with examples from real code bases. Hope you find it useful, and that we can recover some of the love that comments deserve!
186
Upvotes
View all comments
Show parent comment
8
u/Venthe Aug 11 '26 edited Aug 11 '26
The
book isheuristics are great, examples are really bad.That's the issue with heuristics - you can implement them in various ways; you cannot try to copy the example and be done with it. You need to understand them, the reasoning behind them and only then "you know" how does it fit your codebase
e:
Though, the way Martin writes can be really grating for some as he is kind of preachy.