3 ms·
What's the state of safety in zig? does it allow footguns like in C/C++ ? What about borrow checker(it makes program safe. isn't it?)? I would like to know adva
by throwawaydsstr 5y ago
What's the state of safety in zig? does it allow footguns like in C/C++ ? What about borrow checker(it makes program safe. isn't it?)?
I would like to know advantages as well
- holonomically 5y agoThe best answer I can provide is this document: https://ziglang.org/learn/overview/ https://ziglang.org/learn/overview/. It covers the main features of the language and how they compare to other languages like C, C++, and D. I personally think it has enough features like option types instead of null pointers, array bounds checking, generics, compile-time code execution, etc. for writing safe code but others might disagree.
- pcwalton 5y agoZig is not memory safe, and is not meaningfully different from C and C++ in this way.
- ncmncm 5y agoAnyway, not meaningfully different from C.
- verdagon 5y agoI believe it has release-safe mode, which protects against most use-after-free. This is sufficient safety for most applications, IMO. I only see it getting safer from here, with some advances on the horizon, such as memory tagging. The language has a lot of potential.
- dleslie 5y agoZig does not have a borrow checker and allows footguns with relative ease. It's a C replacement, after all. Sounds like you want Nim.