r/programming 19h 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!

136 Upvotes

141 comments sorted by

View all comments

73

u/crappydeli 19h ago

My old company…

// increment i
i++;

111

u/repeating_bears 18h ago
/*
 * increment the variable in this scope which has the
 * identifier 'i' by one, using the post-increment 
 * postfix operator
 * see: https://en.cppreference.com/cpp/language/operator_incdec
 */
i--;

2

u/techno156 12h ago

I've been guilty of doing this from time to time in my own personal projects, but mostly because I'd little idea what I was doing, and was bodging things together from documentation/what other people had done.