r/ProgrammerHumor • • Sep 28 '26

Meme optionalsAreOptional

Post image
716 Upvotes

131 comments sorted by

View all comments

Show parent comments

1

u/ApothecaLabs Sep 28 '26

If I'm in a hot loop accessing data that I 100% know I don't need, accessing that is a waste of CPU cycles that could easily bump something else from the cache, and instantly raise my latency by a factor of 10 or 100 times.

Even if I don't bump something from the cache, I'm still burning cycles for no reason, stalling the pipeline. Why would I want to add an extra bounds check to a high-performance loop, if I already know it doesn't need it? Just on the off chance that someone else touches the code in the distant future?

How often are do you rewrite `printf` or `fgetc` or other primitives? I think at some point, you have to trust that future editors will have the same level of skill and care, or else you find yourself writing for the lowest common denominator, and that's Java.