from Hacker News

Zig: Great Design for Great Optimizations

by gwenzek on 7/3/23, 3:04 PM with 3 comments

  • by lerno on 7/4/23, 9:17 AM

    As a counterpoint, see this blog post on why wrapping-overflow-is-UB is bad for safety and correctness: https://c3.handmade.network/blog/p/7640-on_arithmetics_and_o...

    The gist of it is that (a + b) - c becomes different from a + (b - c) and (a - c) + b.

    While Rust picks a “fast” default that ensures non-trapping code is safe in this regard.

    Zig on the other hand would make incorrect ordering UB which might not be immediately obviously wrong - it completely depends on the optimizations run, something which runs completely counter to notions of correctness.

  • by prabhatexit0 on 7/3/23, 3:22 PM

    Nice article!
  • by nektro on 7/3/23, 5:16 PM

    Interesting!