Re:A categorized list of all Java and JVM features since JDK...
by ragnese on Friday April 02, 2021 @01:26PM
(#26673604)
Yeah, I don't have any real intuition about the performance cost, either. But real-world Haskell problems do fine, as you said. And Haskell has fast-math libraries that, presumably, give you the fast-but-risky C arithmetic.
I also agree that a "more realistic" option is to just throw on overflow by default, the same way we throw on divide-by-zero.
But that won't happen either. :/
A more realistic change might be to have Java default to throwing on overflow. The addExact methods can give this behaviour in Java. In C# it's much more ergonomic: you just use the checked keyword in your source, or else configure the compiler to default to checked arithmetic (i.e. throw-on-exception). This almost certainly brings a performance penalty though.