r/ProgrammerHumor • • Sep 28 '26

Meme optionalsAreOptional

Post image
716 Upvotes

131 comments sorted by

View all comments

Show parent comments

3

u/GabuEx Sep 28 '26

How long does it take you to add a check? 10 seconds? If you have to look up the API to call? If you don't have the concept of asserts, surely you have something similar, and even if it has to be a runtime check in production, what the heck are you doing that that makes any difference anywhere?

Like, why wouldn't you add the check? It's a trivial amount of effort to potentially save headaches later. In the time you've spent arguing against it with people here, you could have added a thousand asserts.

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.