3 ms·
To add more concrete examples, you could look at tagged unions, errorsets and optionals. An `if` statement in Zig has a few different faces, traditional condit
by latch 2y ago
To add more concrete examples, you could look at tagged unions, errorsets and optionals.
An `if` statement in Zig has a few different faces, traditional condition, unwrapping an optional and unwrapping an errorset.
That makes the language "bigger", but these are things you'll regularly face in C anyways, even with trivial examples. I think most of the things Zig (purely as a language) has "added" to be labeled a "Better C" are all pragmatic and don't increase any cognitive load.
The other thing worth mentioning is that Zig has a number of safety advantages. I just touched up my DuckDB driver, and their C API exposes the underlying storage for a column as a (void ), the format of which depends on the column type. In Zig, I can map this to a typed tagged union. For an bigint column, instead of a (void ), I end up with an []i64.