News for hackers. Stuff that matters.
Re:On Comments in Code by cush on Wednesday June 16, 2021 @01:55AM (#27525343)
Until the code changes, then the comments are usually worse than nothing
Re:On Comments in Code by benrbray on Wednesday June 16, 2021 @04:24AM (#27526176)
No. Comments are like a parity check. If the comments don't match the code, then you know that either:

1) The comments are correct, but the code is wrong. This is a bug. 2) The comments are wrong, but the code is correct. This is equally a bug. Whoever makes the change has an obligation to describe their changes with a comment.

Code with no comments? Could be right, could be wrong, who knows?

Re:On Comments in Code by cush on Tuesday June 29, 2021 @09:45PM (#27683986)
Good luck maintaining that.
Re:On Comments in Code by ghoward on Thursday June 17, 2021 @04:23PM (#27544148)
I wish I could upvote your comment more, but putting it in my bookmarks will have to do for now.
Re:On Comments in Code by AlotOfReading on Wednesday June 16, 2021 @03:38AM (#27525921)
I've seen this counterpoint brought up many times before, but I'm struggling to think of the last time I experienced it. Is it really a common problem for you?
Re:On Comments in Code by cush on Tuesday June 29, 2021 @09:49PM (#27684007)
Yes, the issue isn't that most comments are inaccurate, it's that the inaccurate ones are so costly. When the comment doesn't match the code, it makes you question the code and the intent. 90% of the time, comments are accurate or just redundant (the code is descriptive enough), but that 10% of the time when the comments says A and B is happening, I end up chasing down whoever or digging through changelogs and tickets to find the comment wasn't updated.
Re:On Comments in Code by b3morales on Wednesday June 16, 2021 @08:07PM (#27534887)
For the kind of code comment we started this thread talking about (explaining why some simpler/more obvious process is not used), this seems vanishingly unlikely.
Re:On Comments in Code by taneq on Wednesday June 16, 2021 @04:24AM (#27526175)
Then you fire the coder who changed the code without updating the comments?
Re:On Comments in Code by cush on Tuesday June 29, 2021 @09:50PM (#27684012)
Most code doesn't need comments.
Re:On Comments in Code by kwhitefoot on Wednesday June 16, 2021 @05:49AM (#27526671)
That's a waste. Just train them better.