3 ms·
In some ways, Zig is simpler than C, it's true, but it also adds some nice things. For example, Zig introduces a robust error handling mechanism (try, catch, r
by troymc 2y ago
In some ways, Zig is simpler than C, it's true, but it also adds some nice things.
For example, Zig introduces a robust error handling mechanism (try, catch, return err) that eliminates the need for exceptions or manual error checking via return codes (if (ret < 0)).
Also, Zig includes its own build system (zig build) and package management. This removes the need for external tools like make, cmake, or third-party dependency managers. Everything is integrated and works cross-platform out of the box.
You wondered why getting rid of macros was a good idea...
Zig allows compile-time function execution (CTFE) as a core language feature. This replaces the need for macros in many cases. While C macros are powerful, they are also error-prone and hard to debug. Zig's comptime feature allows you to write functions that run during compilation, offering the same benefits but with stronger type safety and clearer error messages.
- jakeStbu 2y agoI see. Better error handling could perhaps be something that C can improve, yes, especially as compared to things like errno (which yes is technically not C specific but rather Linux specific, but it would be good to have a layer of abstraction over this). I can see why Zig Build may be useful - does it have any major advantages over something like, say, Rust's Cargo? I personally find that to be quite powerful. CTFE does sound like it could be easier to debug, but it sounds significantly less powerful and I don't think that it's necessarily worth it in many cases.