Re:Zig's Curious Multi-Sequence for Loops
by conradev on Monday February 27, 2023 @10:07AM
(#34957245)
it is one of the build modes: https://ziglang.org/documentation/master/#Build-Mode
[ Parent
| on HN ]
Re:Zig's Curious Multi-Sequence for Loops
by titzer on Monday February 27, 2023 @10:12AM
(#34957309)
Interesting, thanks for the link.
I think that disabling safety checks is a thing you should only do if you are studying the cost of safety checks (i.e. a compiler switch only available to compiler engineers). IMHO, the whole point of safety checks is to find the bugs that are in your program[1]. Crashing it safely with an exact source stack trace is the nice way of both motivating you to fix it and also helping you fix it.
[1] And there are bugs in your program. Right now. Bugs. In. Your. Program. Running without safety checks is like closing your eyes and rolling the dice.
There's also the compromise of only disabling safety checks per block e.g. in your hot loop with `@setRuntimeSafety`[1] where you are confident that they aren't needed.
[1] https://ziglang.org/documentation/0.10.1/#setRuntimeSafety
Re:Zig's Curious Multi-Sequence for Loops
by laserbeam on Monday February 27, 2023 @11:02AM
(#34957936)
Most software should probably release with safety checks on. Certain software shouldn't (i.e. games). Toolchains like zig give you that option and respect that you can decide what's most appropriate for whatever you ship.
Arguing that safety checks should always be enabled doesn't really make sense. Context matters.