Interesting, not ran across this language yet…
- C++, D, and Rust have operator overloading, so the
+
operator might call a function.
Uh, operators are functions, this always bugs me when someone says this, overloading or not, operators are still functions… >.>
The initialization value of global variables is evaluated at compile-time.
Hmm, looks like it has a built in interpreter to run zig code at compile-time as it calls a function for it, wonder what the limits of that are…
However any type can be made into an optional type by prefixing it with
?
Looks kotlin’y, auto detection of when tested, etc…
Any functions that need to allocate memory accept an allocator parameter.
Interesting, I like that the allocator has to be passed around, makes it very easy to override on a case-by-case basis, definitely something rust got wrong. However it needs to be optionally passed in and 99% of the time you don’t care. In addition, the allocator signature appears… insufficient for proper memory allocation that isn’t coming from a simple x86-like HEAP or so… In addition, how do you free that same memory with the right allocator without passing the allocator everywhere around with it?
Manual memory management
Woo, but what ways does it have to enforce managing it, or any other resource for that matter, properly?
defer
/errdefer
Ogod, don’t like this stuff, it makes it so easy for the user to forget it…
catch
Looks like just an optional deconstructor for returned error values, why not make that generic like rust did…
break
Wait what, really? This is just a goto
here…
try
Oh hey, it’s Rust’s try!
macro, except that rust is getting rid of it because ?
is better.
unreachable
This just looks like Rust’s panic!()
rather than an actual unreachable declaration (which in rust will significantly effect codegen). This really needs to be renamed…
Built in stacktraces on everything
Hrmm, wonder what cost this adds…
Types are values
Interesting, so it definitely has an interpreter at compile-time
typeinfo
Oh yay, and every type is carrying reflection information with it, that’s going to add a pointer to anything passed around via pointers needlessly…
comptime
Ah, forcing a function to run at compiletime can be done via the comptime
keyword, guess that’s just like constexpr
in C++ but in some other contexts.
Resource Management
So the language has no resource management to speak of, short of easy-to-forget defer
/errdefer
calls (which of course constrain the lifetime to the scope only).
Overall it feels more like Go with a bit more training wheels and less GC and more manual resource management of the failed pointer variety, does not feel like a Rust/C++ replacement.
Disclaimer: I’m an OCaml dev for ~10 years off and on, C++ dev for 30 years, Rust dev for ~2 months, plus a ton of other languages jobs depending