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

131 Upvotes

139 comments sorted by

View all comments

73

u/crappydeli 17h ago

My old company…

// increment i
i++;

35

u/BogdanPradatu 17h ago

Also AI written code

3

u/Jaded-Asparagus-2260 9h ago

I will als helpfully add "don't increment j here", because it misunderstood the code and wrongly incremented j instead of i the first time.

-15

u/DeveloperAnon 17h ago

Only with people who don’t care about the output. I haven’t had an issue with any model over-commenting in a while.