Zig: programming language designed for robustness optimality and clarity [video]
I have read quickly through the tutorial, and this looks interesting. Objectives are similar to Rust, with a few twists.<p>A few differences that I can see:<p>- At first glance, Rust&#x27;s `enum` looks safer and more powerful than Zig&#x27;s `union` + `enum`, while Zig&#x27;s `union` + `enum` appears more interoperable with C.<p>- Zig&#x27;s `comptime` is quite intriguing. In particular, types are (compile-time) values and can be introspected.<p>- Zig&#x27;s generics are very different from Rust&#x27;s generics. No idea how to compare them.<p>- In particular, Zig&#x27;s `printf` uses `comptime`, while Rust&#x27;s `print!` is a macro.<p>- Zig&#x27;s Nullable types&#x2F;Result types look bolted in and much weaker than Rust&#x27;s userland implementation.<p>- I don&#x27;t see closures in Zig.<p>- I don&#x27;t see traits in Zig.<p>- I don&#x27;t see smart pointers in Zig, and more generally, I have no idea how to deallocate memory in Zig.<p>- Zig&#x27;s memory management encourages you to check whether your allocations have succeeded, while Rust&#x27;s out-of-the-box memory management assumes that allocations always succeed - if you wish to handle OOM, you&#x27;ll need a &quot;let it fail&quot; approach.<p>- Zig&#x27;s alias checker seems to be much more lenient than Rust&#x27;s.<p>- I don&#x27;t see anything on concurrency in Zig&#x27;s documentation.<p>- Most of the Zig examples I see seem to fall in the &quot;unsafe&quot; domain of Rust by default. For instance, uninitialized memory or pointer casts seem to be ok in Zig (if explicitly mentioned), while they must be labelled as `unsafe` to be used in Rust.<p>- According to <a href="https:&#x2F;&#x2F;andrewkelley.me&#x2F;post&#x2F;unsafe-zig-safer-than-unsafe-rust.html" rel="nofollow">https:&#x2F;&#x2F;andrewkelley.me&#x2F;post&#x2F;unsafe-zig-safer-than-unsafe-ru...</a>, Zig performs some checks that Rust does not perform in an `unsafe` block.<p>- Zig supports varargs, Rust doesn&#x27;t (yet).<p>For the moment, I&#x27;ll keep coding in Rust, but I&#x27;ll keep an eye on Zig :)