Re:Some Thoughts on Zig
by throwaway17_17 on Friday July 22, 2022 @12:17AM
(#32188477)
Slightly off topic, but I would prefer to never see smart pointers in Zig. Smart pointers are an inefficient and semantically-unenforceable ‘solution’ for the wrong problem. Smart pointers are supposed to be a way to handle references to mutable data in concurrent/multi-threaded/distributed computation, however I don’t think they form a satisfactory basis to solve the problem they think they solve. Now, I’m not a fan of Rust’s approach in general or it’s approach to this problem, but at least it is a semantically motivated solution.
If a Zig user wants to restrict usage of pointers in certain ways let them make their own data structures, but unless Zig is willing to alter its semantics including a ‘standard’ smart pointer is putting icing on a cardboard box.
/edited to fix a typo/
This makes something like the use of sanitizers required for large projects in Zig; It's a race against time until your project gets big enough that someone mistakenly frees something that gets used 200 lines later.