3 ms·
Syntax looks almost exactly like Rust with some elements from Go and D. What about memory management ? They say there is no GC so manual memory management? Any
by lossolo 9y ago
Syntax looks almost exactly like Rust with some elements from Go and D.
What about memory management ? They say there is no GC so manual memory management? Any memory safety features ?
- iainmerrick 9y agoThe “defer” statement makes it easy to ensure important code gets run once even if there are multiple returns (along with %defer for error cases). That covers at least 95% of fiddly manual allocation problems -- the kind of thing RAII helps you avoid in C++, or “using” in Python and C#.
- dbaupp 9y agoDeallocating/RAII is not memory safety. Leaking all memory is, in fact, a tried-and-true way to get memory safety (GC'd languages are semantically doing this: GC is "just" an optimization), since it means problems like use-after-free are impossible. Memory leaks are great to eliminate, but they can't lead to the corruption that memory unsafety can cause. http://huonw.github.io/blog/2016/04/memory-leaks-are-memory-safe/ http://huonw.github.io/blog/2016/04/memory-leaks-are-memory-... Rephrasing the parent's question: does Zig try to ensure memory safety (e.g. no use-after-free, dangling pointers, iterator invalidation, data races)?
- eradicatethots 9y agoZig + borrow checker is my ideal language
- fasquoika 9y agoMaybe look at the language that inspired Rust: Cyclone http://cyclone.thelanguage.org/ http://cyclone.thelanguage.org/ . It's just a research language (which the site claims is "done") but maybe worth a look.
- eradicatethots 9y agoSeems pretty cool, too bad it’s dead now though