Comment by dlcarrier
5 hours ago
I just looked up a Hello World program from the Zig Wikipedia article:
const std = @import("std");
const File = std.Io.File;
pub fn main(init: std.process.Init) !void {
_ = try File.stdout().writeStreamingAll(init.io, "Hello, World!\n");
}
That's a lot to follow, just to output a plan-text message, especially after this line: "The primary goal of Zig is to be a better solution to the sorts of tasks that are currently solved with C. A primary concern in that respect is readability…"
I don’t think you can judge a programming language based on its “Hello World.” AppleSoft BASIC has this:
10 PRINT “Hello World”
Beautifully simple and readable. But it’s not a good language by modern standards.
In your example, I see a lot of complexity being surfaced: output streams, locals instead of globals, error handling. I don’t know Zig but all of those are things that are important to address, and I like that the example doesn’t sweep them under the rug in pursuit of a false readability.
Everything it's doing it clear and readable. It's just not as easy to write. It streams the bytes to stdout using the default IO interface, and it can fail.
Alternatively, here's a simpler version (prints to stderr).
In practice, you normally don't want to print messages to stdout. So the increased friction here actually pushes you in a better direction.
Whats the point of evaluating technology from hello world programs?
The issue is that most "hello world" programs are not correct.
While most hello worlds do not check that the message was printed (which I assume writeStreamingAll does for you), dismissing the rest of the differences as "the others aren't correct" isn't really accurate.
Explicitly passing IO in is a fine design choice, but it's not a correctness issue to say others are wrong to not do so.
>While most hello worlds do not check that the message was printed
Should they?
1 reply →