* Type inference - var name = "Bob";
* Maybe types (from Elm/Haskell) that prevent NULL ptr bugs and syntactic sugar encourages its use for function return values.
if (doit()) |result| {
// result is always a populated Struct
} else |err| {
// error is always a populated Error
}
// a return type of !Something means Error type or Something type
fn doit() !Struct {
}
* Nullable types - var ?&object = null; if you need it, and var &object = aObject; if you want the safety.* Great C interop, though there is more work to be done here. (gtk.h for instance is too much for zig today) Zig's approach is unique here too. You specify .h files in the zig source code and the zig compiler translates C in the .h into zig. Its not a function bridge or wrapper, its zig objects and zig functions available to your zig code.
const c = @cImport({
@cInclude("curl/curl.h");
});
var curl = c.curl_easy_init();
if(curl != null) {
_ = c.curl_easy_setopt(curl, c.CURLoption(c.CURLOPT_URL), url_cstr.ptr);
...
* Standard library operations that allocate memory take an 'allocator object' parameter that should give great programmer control over memory management (I didnt get into this myself), webasm is a compiler target, and lots more