3 ms·
Zig is not memory safe, there is no way around it. It's really only as safe as C, with some helpers for making it easier to write safe code. You should really n
by lukaslalinsky 2y ago
Zig is not memory safe, there is no way around it. It's really only as safe as C, with some helpers for making it easier to write safe code. You should really not use Zig unless you are prepared to deal with memory safety on your own. That makes it a good low-level language for system programming, but a VERY bad general purpose language. I'm writing this as a fan of Zig.
- ngrilly 2y agoUnlike C, Zig offers spatial memory safety, but it does not offer temporal memory safety.
- do_not_redeem 2y agoZig only has spatial memory safety in limited situations. For example: If you use many-pointers anywhere in your codebase, those places have no spatial memory safety. If you compile in ReleaseFast, you have no spatial memory safety at all.
- throwawaymaths 2y agoin practice though you should be compiling ReleaseSafe and activating ReleaseFast only in functions where you need it (and that is the default)
- lukaslalinsky 2y agoEven the Zig compiler is built with ReleaseFast for the published binaries.
- throwawaymaths 2y agonot sure what you think the safety parameters for compilation should be.
- dragonelite 2y agoBecause its not so strict and safe as Rust is what brings me joy for hobby and recreational programming. Its easy to track how and when memory is allocated because you need to pass an allocator to do it.