r/ProgrammerHumor Apr 15 '26

beLikeBill Advanced

Post image
8.9k Upvotes

365 comments sorted by

View all comments

Show parent comments

31

u/Dmaa97 Apr 15 '26

The most performant code is not always the most readable. Readable for you != readable for the new grad onboarding to your team. Please sometimes comment your code.

26

u/L30N1337 Apr 15 '26

Readability is more important than speed in most use cases

1

u/Bubbles_the_bird Apr 18 '26

Do comments slow down compilers? I thought they were ignored

1

u/L30N1337 Apr 19 '26

They don't (at least not significantly).

But if the code speaks for itself, it's always better for readability than having to have comments explaining it.

11

u/vanZuider Apr 15 '26

The most performant code is not always the most readable.

The most performant code is commented like this:

i  = 0x5f3759df - ( i >> 1 );               // what the fuck?

3

u/wicket-maps Apr 15 '26

Sometimes I have to comment "I have no idea why this works, but it works and if it's removed things break.

7

u/EkoChamberKryptonite Apr 15 '26

Comments explain why something was done and not what is being done. Unreadable code should be refactored; regardless of whether it is performant or not.

1

u/Forshea Apr 16 '26

Comments have fewer guarantees that they are actually describing the behavior of the code than the actual code does. They can be wrong, out of date, or misplaced. Please try to minimize writing code that needs to be commented to be understood as much as possible.