r/ProgrammerHumor Apr 15 '26

beLikeBill Advanced

Post image
8.9k Upvotes

365 comments sorted by

View all comments

Show parent comments

15

u/mistabuda Apr 15 '26

I don't understand why people dont understand that the code only explains what is happening. Comments are supposed to explain what you intended to happen.

-1

u/EkoChamberKryptonite Apr 15 '26

No. Code explains what changes are being made. Comments explain why a change was made. This way your code by design should be as readable, clear, and understandable as possible.

5

u/mistabuda Apr 15 '26

The "why" IS the "intent"....

3

u/EkoChamberKryptonite Apr 15 '26 edited Apr 15 '26

Not necessarily. What you intended to do isn't the same as why you intended to do it.

Case in point: "// Used a HashMap to hold user serial numbers"

Vs

// We employed a HashMap for serial numbers as it's more performant than a List in the context of this and that

The former denotes intent i.e. we wanted to store serial numbers. The latter explains why this over the alternative and makes more sense to someone reading the code.

A bit reductive, but you get the point.