Time to move std.experimental.checkedint to std.checkedint ?
Vladimir Panteleev
thecybershadow.lists at gmail.com
Wed Mar 31 07:31:21 UTC 2021
On Wednesday, 31 March 2021 at 07:13:07 UTC, Walter Bright wrote:
> All I can say is code gen is never that simple. There are just
> too many rules that conflict. The combinatorial explosion means
> some heuristics are relied on that produce better results most
> of the time. I suppose a good AI research project would be to
> train an AI to produce better overall patterns.
>
> But, in general,
>
> 1. LEA is faster for more than one operation
> 2. using fewer registers is better
> 3. getting locals into registers is better
> 4. generating fewer instructions is better
> 5. generating shorter instructions is better
> 6. jumpless code is better
Thanks for the insight!
My personal perspective is that:
- Silicon will keep getting faster and cheaper with time
- A 7% or a 14% or even a +100% slowdown is relatively
insignificant considering the overall march of progress - Moore's
law, but also other factors such as the average size and
complexity of programs, which will also keep increasing as people
expect software to do more things, which will drown out such
"one-time" slowdowns as integer overflow checks
- In the long term, people will invariably prefer programming
languages which produce correct results (with less code), over
programming languages whose benefit is only that they're faster.
So, it seems to me that Rust made the choice to only enable
overflow checks in debug mode in order to be competitive with the
programming languages of its time. I think Zig's design is the
more future-proof - there will continue to be circumstances in
which speed is preferable over correctness, such as video games
(where an occasional wrong result is tolerable), so having
distinct ReleaseFast and ReleaseSafe modes makes sense.
BTW, another data point along Rust and Zig is of course Python 3,
in which all integers are BigInts (but with small numbers inlined
in the value, akin to small string optimizations).
More information about the Digitalmars-d
mailing list