Hello world circa Zig 0.1.1

I’m in the process of rebuilding some demos that I have. One of them happens to be using the tarball of Zig 0.1.1 as input data. I found it amusing looking at this really early version. Thought maybe you guys would be amused too.

Here’s the “hello world” program:

const io = @import("std").io;

pub fn main() -> %void {
    %return io.stdout.printf("Hello, world!\n");
}

I didn’t start tracking the project until 0.10.0 so I missed out on percentage-sign era. What was the thinking behind that?

Here’s the link to my demo app if you want to look at other files in the earliest of Zig tarballs.

18 Likes

I haven’t seen the percentage sign syntax either, how curious! I love little historical things like this; thanks for sharing.

1 Like

This is probably just the author’s personal preference. I’m also designing a query language, but my approach is different.
I’m trying to take the best practice from various languages.

The percentage sign seems to be related to error handling. From example/cat/main.zig:

            var is = io.InStream.open(arg, null) %% |err| {
                %%io.stderr.printf("Unable to open file: {}\n", @errorName(err));
                return err;
            };

They are indeed error handling, here’s a post detailing why and how they got replaced:

4 Likes