Rendered at 16:26:52 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
bayesnet 1 hours ago [-]
As someone who doesn’t write Zig, I wish the code examples gave type annotations for the writers so I could see the difference between the old generic API and the new `std.Io` interface.
sarreph 1 hours ago [-]
As someone who doesn't write Zig (but is hoping to soon!), I'm struck when reading this that the new interface seems much more verbose than the old interface... i.e. 6 LoC vs the previous implementation's 3 LoC.
I was under the impression that verbosity was something that Zig tries to reduce, but perhaps this is not emblematic of other updates to the language?
wmedrano 1 hours ago [-]
Zig is more about "no hidden control flow" than conciseness.
Counting LoC in boilerplate is somewhere between silly and absurd ... there's just one instance of those lines for a large body of code.
And no, reducing verbosity is really not a Zig thing.
PunchyHamster 9 minutes ago [-]
At glance it looks more of "performance vs readability" tradeoff. Not sure if making every IO handling code look worse is worthy tradeoff.
Jowsey 2 hours ago [-]
So many Claude-isms in one post. Please stop.
Nail2680 2 hours ago [-]
Needing to manually call flush seems like a major issue, is there a friendlier wrapper in the std lib to print and flush and use some static storage for the buffer? Since that seems like it would become step one of any zig project
KolmogorovComp 1 hours ago [-]
I agree, the less batterie-complete STD become, the more everyone get its own half-baked utility one.
eptcyka 1 hours ago [-]
It mirrors the C interface.
metaltyphoon 52 minutes ago [-]
Well, printf flushes when \n is encountered. Does zig have something similar?
PunchyHamster 8 minutes ago [-]
Why I would want that brought into new language?
qalmakka 19 minutes ago [-]
I don't know. I know that the old interface was less pleasant than it could be, but breaking every single program ever written in Zig to change it for a super unwieldy API felt to me more like the authors being unnecessarily fastidious than striving for "no hidden control flow". Every single language has a shitty API or two - it's impossible to have none, and to be fair the new one is way too clunky anyway.
Like, what does "avoiding hidden control flow" even mean? What value there is in having no convenient facility to do buffered I/O? Hidden buffered output wasn't really a problem even 40 years ago, it's one of those things everybody needs and those who don't are well aware of how to use the primitives and do it properly.
But let's be clear, I have nothing against Zig, I quite like it from a language nerd standpoint and I think it's very neat - I just don't understand what is the intended target to be honest. If I'm not looking for a safe language, C is fine, and for all its warts and bullshit C++ works with basically everything under the sun. If I want safety, there is Rust which basically already enforces the same patterns you need to follow to get safe C/C++ programs anyway - in my experience, 99% of the time someone whines that the borrow checker is stopping them from doing something, it's because they are making a massive logic mistake and they didn't notice there's some hidden unsoundness (like pointers with unclear lifetimes, etc).
delusional 1 hours ago [-]
This reads either AI generated, or written by someone who has gotten too used to AI writing. The structure is off and filled with "Here's what happened next" and "Why that matters" and "X happens, not Y" without context for why I'd care, or why I'd expect Y.
I was under the impression that verbosity was something that Zig tries to reduce, but perhaps this is not emblematic of other updates to the language?
https://ziglang.org/learn/overview/#small-simple-language
And no, reducing verbosity is really not a Zig thing.
Like, what does "avoiding hidden control flow" even mean? What value there is in having no convenient facility to do buffered I/O? Hidden buffered output wasn't really a problem even 40 years ago, it's one of those things everybody needs and those who don't are well aware of how to use the primitives and do it properly.
But let's be clear, I have nothing against Zig, I quite like it from a language nerd standpoint and I think it's very neat - I just don't understand what is the intended target to be honest. If I'm not looking for a safe language, C is fine, and for all its warts and bullshit C++ works with basically everything under the sun. If I want safety, there is Rust which basically already enforces the same patterns you need to follow to get safe C/C++ programs anyway - in my experience, 99% of the time someone whines that the borrow checker is stopping them from doing something, it's because they are making a massive logic mistake and they didn't notice there's some hidden unsoundness (like pointers with unclear lifetimes, etc).