Hacker News new | ask | show | jobs
by hyperhopper 1251 days ago
Our processors also require manually manipulating registers.

The whole point of higher level programming languages is to abstract away the fiddly bits of dealing with processors that we don't want to have to deal with.

This is one of those cases.

2 comments

In this case it's really that the cost of determining if an overflow did occur or will occur on modern architectures is too high and the likelihood too low for it to be reasonable to perform the checks in most cases in native code. Might be different for interpreted languages depending on a lot of things (whether or not they even use integer arithmetic, whether or not they default to some arbitrary precision integers by default, etc.). If common architectures automatically interrupted on overflow rather than setting a flag at no additional cost, I'd think you'd see safety guarantees instantly.
In cases where you're willing to take the perf hit, you can just use languages like Python which abstract over integer size entirely.
Which used to, but at least for parsing ints they've snuck in the perf hit as a "security vulnerability."