#How does Zig’s safety features compare to Rust? Will Zig ever adopt a borrow checker?
1 messages · Page 1 of 1 (latest)
What safety are you looking for
Memory safety I guess we have the slices index-out-of-bounds panics on debug/release-safe
Some safety-related proposals for Debug and Safe modes
https://github.com/ziglang/zig/issues/63
https://github.com/ziglang/zig/issues/3180
https://github.com/ziglang/zig/issues/1966
https://github.com/ziglang/zig/issues/2301
Probably not a borrow-checker though
If the zig server is done soon, probably a Borrow Checker on top of that could exist
I have a few ideas
👀
A borrow checker would be an interesting debug feature but I'm not sure I understand how it would work with Zig's semantics in general
A lot of kinks to work out
So getting in the question, Zig wants also to provide tooling to check this stuff
not integrated in the language itself, but letting people build on top of the toolchain
On top of what already the language have checks for
Yeah, well put - the general approach has been to include ways to detect bad behavior when running the program, like ubsan, Valgrind, tracing integration, rather than intrusive language constructs
Zig offers spatial, but not temporal safety, see https://github.com/ziglang/zig/issues/2301#issuecomment-804496642.
Zig could allow external tooling to offer borrow checking, but to make this reasonable this would require a standard format for code annotation semantics and if Zig wants to rule out conflicting annotation semantics package system integration, see https://github.com/ziglang/zig/issues/14656#issuecomment-1437639789
I think something more akind to semantics of RefinedC as general solution would be more feasible, but composable proof code / annotations is still research.