|
|
|
|
|
by drjeats
305 days ago
|
|
> Then why do my data structures detect if I go out of bounds? Because you have iterator debugging and/or assertions turned on and are only using non-primitive data structures (e.g. std::vector, std::array). Zig does the thing that Rust and Go do where it makes the primary primitive for pointers to chunks of memory (slices) bounds checked. You can opt out with optimization settings, but I think most programs will build in "safe release" mode unless they're very confident in their test coverage. It's strictly better than C++, because in practice codebases are passing lots of `(data, len)` params around no matter how strongly you emphasize in your style guide to use `std::span`. The path of least resistance in Zig, including the memory allocator interface, bundles in language-level bounds checking. |
|
Do you have any citations to support this 'safe release' theory? Like there are not many Zig applications and not many of them document their decisions. One i could find [1] does not mention safe anywhere.
1. https://ghostty.org/docs/install/build