back

by sarreph·1d ago·view on hn ↗
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?

3 comments
Zig is more about "no hidden control flow" than conciseness.

https://ziglang.org/learn/overview/#small-simple-language

Counting LoC in boilerplate is somewhere between silly and absurd ... there's just one instance of those lines for a large body of code. 3 more lines is not "much more verbose".

Old way to write: try writer.print("Hello {s}\n", .{"world"});

New way to write: try writer.print("Hello {s}\n", .{"world"});

And no, reducing verbosity is not a Zig thing. And there were far more important goals driving WriterGate than verbosity -- there were problems to be solved. If they could have been solved less verbosely then perhaps they would have been.

At glance it looks more of "performance vs readability" tradeoff. Not sure if making every IO handling code look worse is worthy tradeoff.
Old way to write: try writer.print("Hello {s}\n", .{"world"});

New way to write: try writer.print("Hello {s}\n", .{"world"});