Useful and Useless Code Comments
Jim Nielsen pushes back on the familiar advice that writing obvious comments is bad practice, noting that he writes such comments all the time. When someone claims a comment adds no value, his response is to ask: to whom?
Nielsen presents examples of comments that match the code at the same level of fidelity—the cases where judging value is most difficult.
// this function adds two numbers
function add(a, b) {
return a + b;
}
It is easy to point at that and call it not useful. The author tends not to leave this kind of comment, but concedes it is fair for Nielsen to question that habit. Comments can serve a wide range of people who may interact with the code at some point, so why gate-keep them?
Nielsen argues that comments serve a very different purpose when they are being read versus when they are being written—almost two different activities. The author adds that they also serve a different purpose when revisiting old code versus actively working on it, and again when doing code review versus directly contributing.



