by croes · 10mo ago · 0 comments
If that needs a why it’s a why-comment.
If it needs a what it’s a what-comment. Especially if clever programming tricks are used. 6 month later you already forgot what the trick is and how it works.
The "why" is the part of the explanation that can't be deduced from the code.
https://en.wikipedia.org/wiki/Fast_inverse_square_root
That definitely needs a what comment.
But there's also the case to be made that the comments that particular code needs are "why" comments. I can see what happens, but why does it work?
The article mentions the reason for the code which I would expect in the commit message