Hacker News new | ask | show | jobs
by metaltyphoon 315 days ago
So… pretty much how C does it.
3 comments

Zig is basically the safety of Modula-2, with a revamped C like syntax, which is why it feels too little for a 2025 language.

Naturally the comptime part is new, but I wouldn't pick a language only because of that.

Well, to look at it optimistically, it's meant as a foundational language, to take over the role C still has today, of being the only true glue language that can underlie all the others. If Zig can actually take over that function, then it will be a major upgrade to the ecosystem, even though it will never be the language of choice for most projects.
Despite all my bashing regarding C, I would rather keep C around with a standard -fhardening, -fsafe, or whatever, with similar constraints, enabling enums without implicit numeric conversions, standard library types for arrays and strings, no decays of arrays into pointer.

Probably more than enough if we leave C as a kind of portable Assembler role, to be used as much as Assembly is, and leave everything else to safer managed languages.

A model just like UNIX authors themselves have applied when creating Inferno with Limbo, with the learnings of UNIX and Plan 9.

Not a fan of @, !, .{ } all over the place, or the struct based imports that look like Javascript require() instead of a proper module system.

The main difference is that C doesn't have error (result types) baked into the language. So the expectation would be in the Zig example above, the calling function would never even bother to inspect the error details, unless the error path was triggered by the called function.
Culture and coding standards count for a lot. C _can_ do this, but it's not normal to.

If Zig can foster a culture of handling errors this way, it'll be the way the community writ large handle errors.

It's still complete dogshit not to be able to have data there. Odin is much better here, iirc