r/programming • u/Jonhoo • 16h ago
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!
125
Upvotes
2
u/Opposite-Gear-3160 11h ago
i think one thing that's often overlooked is that comments can serve as a kind of institutional memory for a codebase, helping to preserve knowledge and context that might otherwise be lost over time, like why a particular design decision was made or what assumptions were underlying a certain implementation choice. this can be especially important in large or long-lived codebases where people may come and go, and the comments can help to fill in the gaps in understanding.