News for hackers. Stuff that matters.
Re:Why Not Comments by readthenotes1 on Tuesday September 10, 2024 @07:00PM (#41506506)
"The comment for the code tells you what the author intended it to do."

Not quite.

The comment for the code tells you what the author of the comment understood the code to do when hen wrote the comment.

Re:Why Not Comments by PlunderBunny on Tuesday September 10, 2024 @07:58PM (#41506871)
It could be that too, but I think that presumes an order - that the comment was written after the code. If the comment was written before the code, then it would describe what the author was trying (intended) to do. Which also implies an order of course.
Re:Why Not Comments by g-b-r on Tuesday September 10, 2024 @08:14PM (#41506979)
Yeah, absolutely check who wrote a comment before relying on it

It's luckily rare for people to add wrong comments, though (and those who do should be publicly fustigated).

By the way, please never state something as it were the truth if you're not sure that it is. Saying "I think" is perfectly fine, and might save people days of investigation.

Re:Why Not Comments by kristiandupont on Wednesday September 11, 2024 @01:53AM (#41508393)
Not the comments I write.

I don't write what the code does or even what "I understand the code to do". I explain choices, especially ones that the next developer or my future self is likely to misunderstand when looking at the code.

Re:Why Not Comments by readthenotes1 on Thursday September 12, 2024 @09:25AM (#41520672)
But what about a year later when someone's changed the code but not the comment?
Re:Why Not Comments by kristiandupont on Thursday September 12, 2024 @12:58PM (#41522963)
I would say that I have observed something like this about as many times as someone has changed some semantics in a way that a variable or function name is no longer correct. That is to say: probably a few times in 25 years, but nothing compared to how much value I have received from them.
Re:Why Not Comments by ykonstant on Wednesday September 11, 2024 @02:52AM (#41508693)
>when hen wrote the comment.

I've always said coding is a cottage industry!

Re:Why Not Comments by CRConrad on Thursday September 12, 2024 @03:10AM (#41518291)