Hacker News new | ask | show | jobs
by lmm 701 days ago
> Sure, we can remove '/' and make that a happy face emoji but I don't think that changes the premise here.

Disagree. The whole point of calling it '/' is to tell the reader that it is mathematical division.

> Making sure you don't divide by zero is just one of those things programmers learn... like making sure you don't derefence null or go beyond the size of your array, or overflowing... not clear to me that masking that helps, maybe the ship wouldn't strand but instead it'd run into a bridge.

In all of those cases it's much better for your program to explode quickly and loudly than silently continue (e.g. you'd hope dereferencing null triggered an error rather than just letting your program continue). Defining x/0 = 0 is masking the error and continuing, which tends to lead to corrupt data and silent wrong results.

1 comments

Yeah, we agree on that last bit. Though technically exploding is also a "wrong result" as we saw with Crowdstrike...