Live data from Hacker News

Why is Zig so cool?

nilostolte.github.io

251–260 of 527 posts

Re: Why is Zig so cool?

#251
post #46

There's at least 1 thing that Zig is better than Rust is that Zig compiler for Windows can be downloaded, unzipped then used without admin right. Rust needs msvc, which cannot be installed without admin right. It is said that Rust on Windows can use cygwin but I cannot make it work even with AI help.

cygwin is a POSIX-emulating library intended for porting POSIX-only programs to Windows. That is: when compiling for cygwin, you'd use the cygwin POSIX APIs instead of the Windows APIs. So anything compiled with cygwin won't be a normal Windows program.

There's no reason to use cygwin with Rust, since Rust has native Windows support. The only reason to use x86_64-pc-cygwin is if you would need your program to use a C library that is not available for Windows, but is available for cygwin.

If you don't want to/can't use the MSVC linker, the usual alternative is Rust's `x86_64-pc-windows-gnu` toolchain.

Re: Why is Zig so cool?

#252

In my opinion the biggest issue of Zig is that it doesn't allow attaching data to error. The error can only be passed via side channel, which is inconvenient and ENOURAGES TOOL DEVELOPERS TO NOT PASS ERROR DATA, which greatly increase debugging difficulty. Somethings there are 100 things that possibly go wrong. With error data you can easily know which exact thing is wrong. But with error code you just know "somethin…

There are plans in Zig to allow to include custom information into error stack trace https://github.com/ziglang/zig/issues/14446 . But that is not implemented. In any case, when debugging annotating error with extra context often is not enough. One often needs a detailed trace of what happens before. So what I would like to see in any programming language is ability to do a structured logging with extra context from…

Not this is explicitly marked as Not Planned

Re: Why is Zig so cool?

#253

Earlier quoted context omitted.

Rust's solution to this is quite good, that's 0..9 and if you want to include 9 it's 0..=9, it looks a bit funny but knowing one with an = sign in it exists removes any doubt

Adding additional syntax to a language for this case seems bonkers to me. People can just write 0..10.

It's more meant for usage with variables:

  for i in 0..length {
    …
  }

  for i in 0..=maxindex {
    …
  }

Re: Why is Zig so cool?

#254
post #83

Earlier quoted context omitted.

This seems kinda contrived. In practice that "ERROR DATA" tends not to exist. Unexpected errors almost never originate within the code in question. In basically all cases that "ERROR DATA" is just recapitulating the result of a system call, and the OS doesn't have any data to pass. And even if it did, interpreting the error generally doesn't every work with a microscope over attached data. You got an error from a wri…

I think you've skipped over all the cases where knowing the filename is actually helpful? It's true that sometimes it isn't. Also, a line number is often helpful, which is why compilers include it. Some JSON parsers omit that, which is annoying.

> Also, a line number is often helpful

That's not error data, that's (one level of) a stack trace. And you can do that in zig, but not by putting call stack data into error return codes.

The conflation between exception handling and error flagging (something that C++ did largely as a mistake, and that has been embraced by managed runtimes like Python or Java) is actually precisely what this feature is designed to untangle. Exception support actually turns out to have very non-trivial impact on the generated code, and there's a reason why languages like Rust and Zig don't include them.

Re: Why is Zig so cool?

#255
post #91

I've heard good things about Zig. I want to pick it up and experiment with it but at ~2% market share I find it hard to justify spending the time to learn and master it right now. It's usually much easier to find the time to learn a new language if there is a project (work or open source) that is also using it. https://survey.stackoverflow.co/2025/technology

It can be useful sometimes to learn things irrespective of what the rest of the world thinks of them.

My personal experience was (back in 2019) that Zig was basically a language you could learn in a weekend and end up being reasonably productive after a week. With that in mind, you might find that you can try it out and either find something that you really like in it and continue, or simply drop it (I ended up picking Odin over Zig, for example, and have found it delightful even 1+ years into production).

The truth is that if you only ever learn what is already popular you'll end up being the professional equivalent of a gray mass with zero definition and unique value proposition.

Re: Why is Zig so cool?

#256
post #20

Is it cool? It seems to be in nether land between Rust and Go. Not sure what is the unique use case for Zig.

We could not have written TigerBeetle, at least not the way it is, without Zig: https://tigerbeetle.com/blog/2025-10-25-synadia-and-tigerbee...

TigerBeetle has a clear purpose and needed those brilliant optimizations. Do you think Zig is suitable as, say, a Go replacement for prod network services and such?

Aside from the fact that Zig is still a bit immature in its std library and ecosystem, I mean. Is it a suitable systems language going forward?

Re: Why is Zig so cool?

#257

Earlier quoted context omitted.

The better solution to forgetting whether an interval is closed or half-open is to always use only half-open intervals, without any exceptions. In most cases half-open intervals result in the simplest program, so I agree with the choice of Zig, which is inherited from other languages well-designed from this point of view, e.g. Icon. I find half-open intervals more intuitive than either closed intervals or open interv…

> always use only half-open intervals That means you have to waste bytes for the index when you need to include ..._MAX.

By "..._MAX" I assume that you mean the maximum value of a given integer type.

In a language where half-open intervals are supported consistently in all the places, this would be solved trivially, e.g. for a signed byte the _MIN and the _MAX values would be defined as -128 and +128, more intuitively than when using closed intervals, where you must remember to subtract 1 from the negated minimum value.

Even the C language has some support for half-open intervals, because the index pointing after the last element of an array is a valid index value, not an out-of-range value (though obviously, attempting to access the array through that index value would be trapped as an out-of-range access, if that is enabled).

Applied consistently, the same method would ensure that the value immediately above the last representable value of an integer type is valid in ranges of that type, even if it would be invalid in an expression as an operand of that type.

Re: Why is Zig so cool?

#258

Earlier quoted context omitted.

As much as I dislike Rust, I gotta give it credit where it's due. It has something unique: a borrow checker. What is so unique in Zig?

> It has something unique: a borrow checker. Rust's borrow checker isn't unique either but was inspired by Cylone: https://en.wikipedia.org/wiki/Cyclone_(programming_language) IMHO a programming language doesn't need a single USP, it just needs to include good existing ideas and (more importantly) exclude bad existing ideas (of course what's actually a good and bad idea is highly subjective, that's why we need many p…

Rust's borrow checker is unique in the sense that it is production-ready. Cyclone is indeed prior art, but it's not as if it ever got beyond the research project stage.

Re: Why is Zig so cool?

#259

> Zig for ( 0..9 ) |i| { } > C for (i = 0; i I know an open interval [0..9) makes sense in many cases, but it's counterintuitive and I often forget whether it includes the last value or not. It's the same for python's range(0, 9).

I completely agree. One of Zig's big competitors, Odin, has a more explicit syntax for this where `0..<5` is an open interval and `0...5` is closed.

I even forget which word means what, "open", "close"

Re: Why is Zig so cool?

#260

The article's claim of Zig being a "totally new way to write programs" is quite mad but I'd like to make a different claim: Zig's own development is a totally new way of writing programming languages (or is at least very rare). While I don't wholly agree with all choices made by Andrew and the Zig team, I greatly appreciate the care with which they develop features. The slow pace of deliberating over features, refini…

I am not sure if a slow pace is as beneficial as you say. I scrolled through the error handling issue brought up in this comment section ( https://github.com/ziglang/zig/issues/2647#issuecomment-2670... ) and its clear that only thing that happened there was communication on the issue was hindered. I come from C++ side and our "ISO C++ committee" language development process leaves a lot to be desired. Now look at error handling that they did passed in C++23 ( std::expected ). It raises some questions on how slow you can be while still appearing to be moving forward.

Disclaimer: I would like to see Zig and other new languages to become a viable alternatives to C++ in Gamedev. But I understand that it might happen way after me retiring =)

Post reply on HN