ES version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
78% Positive
Analyzed from 503 words in the discussion.
Trending Topics
#zig#interfaces#interface#release#nice#easily#more#right#https#codeberg

Discussion (16 Comments)Read Original on HackerNews
Small integers auto coercing into floats is a nice gift to game devs. It's nice that game dev is acknowledged as one of the niches Zig can target as I believe it could really thrive there due to how easily it can integrate with C & C++. Or, rather, more easily than the alternatives.
The idea is to offer some kind of CLI parsing in the std. It says minimal, but the discussion also veers into some more advanced options.
The discussion resulted in two PRs (that I know of):
- Type-driven: https://codeberg.org/ziglang/zig/issues/30677
@dotcarmen extracted it into a package (https://codeberg.org/dotcarmen/clip) so people could more easily try it out.
- Composition-based: https://codeberg.org/ziglang/zig/pulls/31620
If you're familiar with Rust's clap, it's a bit like derive vs builder API.
You can also see how each approach would look in practice if you inspect the diff for the "tools" directory on the PRs.
Also I thought Zig doesn't have interfaces....how does the IO one work?
Also, Zig's tagged unions (enums with payloads in Rust) are really ergonomic and often what you want instead of interfaces. Alot of languages that use interfaces simply don't expose a good way of doing it so everyone reaches for interfaces by default. But if you don't need an actual interface then this way you don't even have to pay the cost of runtime dynamic dispatch.
Which is basically how most device drivers in OSes that happen to be written in C, including UNIX flavours, work.
Love this line from the release notes:
> Lo! Lest one learn a lone release lesson, let proclaim: "cancelation" should seriously only be spelt thusly (single "l"). Let not evil, godless liars lead afoul.