Live data from Hacker News

Zig 0.9.0

ziglang.org

11–20 of 250 posts

Re: Zig 0.9.0

#11
post #7

Is there a good "Why Zig" writeup motivating the language? I've been looking around their web site and the only thing I could find was pretty generic: Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

In addition to the other recommendations, the Zig Zen[0] and The Road to Zig 1.0[1] are pretty convincing.

[0] https://ziglang.org/documentation/master/#Zen

[1] https://www.youtube.com/watch?v=Gv2I7qTux7g

Re: Zig 0.9.0

#12

I don't know if string handling has been improved, but it's one of the few things stopping me from using Zig. I look forward to 1.0, which will hopefully have proper strings. [0] [0]: https://github.com/ziglang/zig/issues/234

IMHO Zig's builtin string handling (or rather, lack of) is exactly right for a systems programming language. Zig avoids the biggest problem of C strings and treats strings as ptr/length slices, not as zero-terminated. UTF-8 for string literals is also fine.

That's all that's needed (and should be implemented) on the language level, everything else should go into the standard library, and additional specialized string processing libraries (because string handling can never be a "one-size fits all" solution, it's too complex for that).

Re: Zig 0.9.0

#13

Is there a story behind the cartoon lizards? Are they like the Zig mascot or something? Seems like they only started appearing since the last release, but they're not explained (unless I missed it).

The one in the jetpack has been around for a couple years, iirc.

Re: Zig 0.9.0

#14
Compiler error for unused variables :( [0]. Possibly my most hated feature of Go.

[0] https://ziglang.org/download/0.9.0/release-notes.html#Compil...

Edit: To be clear, love enforcing the idea for production code, but wish they had embraced a '-dev' mode or equivalent flag that made it easier to experiment.

Re: Zig 0.9.0

#15

Compiler error for unused variables :( [0]. Possibly my most hated feature of Go. [0] https://ziglang.org/download/0.9.0/release-notes.html#Compil... Edit: To be clear, love enforcing the idea for production code, but wish they had embraced a '-dev' mode or equivalent flag that made it easier to experiment.

If a local is intentionally unused, it can be discarded, like this:

test "example" {

    var x: i32 = 1234;

    _ = x;
}

Do discards not fulfill your use case?

Re: Zig 0.9.0

#16

Compiler error for unused variables :( [0]. Possibly my most hated feature of Go. [0] https://ziglang.org/download/0.9.0/release-notes.html#Compil... Edit: To be clear, love enforcing the idea for production code, but wish they had embraced a '-dev' mode or equivalent flag that made it easier to experiment.

One problem I see with this decision is that code will now be littered with:

    _ = bla;
    _ = blub;
...which have been forgotten during development.

So the next thing that's needed is an error if 'bla' or 'blub' are actually used elsewhere ;)

Re: Zig 0.9.0

#17

Compiler error for unused variables :( [0]. Possibly my most hated feature of Go. [0] https://ziglang.org/download/0.9.0/release-notes.html#Compil... Edit: To be clear, love enforcing the idea for production code, but wish they had embraced a '-dev' mode or equivalent flag that made it easier to experiment.

One problem I see with this decision is that code will now be littered with: _ = bla; _ = blub; ...which have been forgotten during development. So the next thing that's needed is an error if 'bla' or 'blub' are actually used elsewhere ;)

I've been 99% a Go developer since 2015-ish, and this is not something I've ever encountered, in general people just don't leave unused variables lying around. The compile time check does highlight logic errors frequently enough though, so I'm very glad it's there.

Re: Zig 0.9.0

#18

Compiler error for unused variables :( [0]. Possibly my most hated feature of Go. [0] https://ziglang.org/download/0.9.0/release-notes.html#Compil... Edit: To be clear, love enforcing the idea for production code, but wish they had embraced a '-dev' mode or equivalent flag that made it easier to experiment.

One problem I see with this decision is that code will now be littered with: _ = bla; _ = blub; ...which have been forgotten during development. So the next thing that's needed is an error if 'bla' or 'blub' are actually used elsewhere ;)

Sure, but this is an easy thing to audit for (could even be automated as part of some CI system, if you wanted).

Re: Zig 0.9.0

#19

Compiler error for unused variables :( [0]. Possibly my most hated feature of Go. [0] https://ziglang.org/download/0.9.0/release-notes.html#Compil... Edit: To be clear, love enforcing the idea for production code, but wish they had embraced a '-dev' mode or equivalent flag that made it easier to experiment.

If a local is intentionally unused, it can be discarded, like this: test "example" { var x: i32 = 1234; _ = x; } Do discards not fulfill your use case?

[deleted]

Re: Zig 0.9.0

#20

Compiler error for unused variables :( [0]. Possibly my most hated feature of Go. [0] https://ziglang.org/download/0.9.0/release-notes.html#Compil... Edit: To be clear, love enforcing the idea for production code, but wish they had embraced a '-dev' mode or equivalent flag that made it easier to experiment.

I like this feature. It has saved me from annoying bugs multiple times in Go during refactoring.
Post reply on HN