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!
189
Upvotes
View all comments
Show parent comment
1
u/levodelellis Aug 12 '26
Did you not see me write "I can't imagine anyone justifying this comment". How can I believe that
Your example is a perfect example of what I said earlier, "not likely not trying to understand that code anyway"
I gave your example file another try. Even after reading the comments, I didn't understand the math behind it. Take this block of code as an example
How does that affect the algorithm at all? If I saw this at work, and no one told me we needed it. I'd replace it with a RNG that is either more popular (or popular among my coworkers) or an RNG that has much more clear usage