Live data from Hacker News

Why is Zig so cool?

nilostolte.github.io

361–370 of 527 posts

Re: Why is Zig so cool?

#361
post #356

Earlier quoted context omitted.

> That's not error data, that's (one level of) a stack trace. They're not talking about the stack trace, but about the common case where the error is not helpful without additional information, for example a JSON parsing library that wants to report the position (line number) in the string where the error appears. There's no way of doing that in Zig, the best you can do is return a "ParseError" and build you own, non…

Another way to look at this example is that, for the parser, this is not an error. The parser is doing its job correctly, providing an accurate interpretation of its input, and for the parser, this is qualitatively different from something that prevents it doing its job (say, running out of memory).

At the next level up, though, there might be code that expects to be able to read a JSON config file at a certain location, and if it fails, it’s reasonable to report which file it tried to read, the line number, and what the error was.

Re: Why is Zig so cool?

#362

Earlier quoted context omitted.

>The feature I want is multimethods -- function overloading based on the runtime (not compile time) type of all the arguments. >Programming with it is magical, and its a huge drag to go back to languages without it. Just so much better than common OOP that depends only on the type of one special argument (self, this etc). Can you give one or two examples? And why is programming with it magical?

For a start it means you can much more naturally define arithmetic operators for a variety of built in and user-defined types, and this can all be done with libraries not the core language. Because methods aren't "inside" objects, but just look like functions taking (references to) structs, you can add your own methods to someone else's types. It's really hard to give a concise example that doesn't look artificial, b…

Thanks.

Re: Why is Zig so cool?

#363

zig is not cool at all, its ugly as sin, and has zero use case other than mingling with legacy c code, and who in their right mind wants to be doing that its a hipster language, absolute insanity to use it when rust exists unless you have that very specific c related slave work to do

> its ugly as sin

Uncalled for and subjective. Certainly plenty of people call Rust's syntax ugly. Discussing syntax and not semantics is a waste of time.

> has zero use case other than mingling with legacy c code

So it has a use case?

> who in their right mind wants to be doing that

Some people have to.

> absolute insanity to use it when rust exists unless you have that very specific c related slave work to do

Some people do.

What's the need for such emotionally charged language in your comment?

I have my own reasons not to use Zig at this moment. I want enforced memory safety and am waiting on 1.0 to see what the language finally looks like. Until stabilization I certainly won't be using it in production. But that doesn't mean the project is meritless, that experimenting with language features before then is wrong, that making a language suitable for specific niches is a bad idea.

I don't see Zig as a replacement for tools that would have been written in Go, Java or C#, and I would rather we had less memory unsafe software out there, but it is a clear step function ahead of C.

Just like I and many others spend a lot of time trying to make Rust the best it can be, their team is doing the same.

Re: Why is Zig so cool?

#364
post #335

Earlier quoted context omitted.

I've learnt this the hard way. The most important thing is to get you to click. Sometimes I'll first iterate over the title before even writing on substack.

Oh, and I just submitted a link to my article about C. I am pretty sure no one will click it. Articles about C never get much traffic, but that is fine. I wrote it because I care about how things really work, not because I expect it to trend. If even a few people read it and see the beauty in the old language that still runs the world, that is enough.

I would like to find more articles on C so feel free to share, thanks

Re: Why is Zig so cool?

#365
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.

It's more of an in-between C and Rust than Go as it is a systems language with no built-in garbage collector for memory management. It has a lot of memory safety features, but it's not as memory safe as Rust. However, it avoids a lot of the complexity of Rust like implicit macro expansion, managing lifetimes, generics and complex trait system, etc. It also compiles much more compactly than Rust, in my experience. In…

> managing lifetimes

If you are not using a GC language, you WILL be managing lifetimes. Rust just makes it explicit, when the compiler can’t prove it’s safe, which Zig, C don't really care.

Re: Why is Zig so cool?

#366
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...

Read that and what part of that can’t be done in Rust in 2025?

Re: Why is Zig so cool?

#367
post #335

Earlier quoted context omitted.

Oh, and I just submitted a link to my article about C. I am pretty sure no one will click it. Articles about C never get much traffic, but that is fine. I wrote it because I care about how things really work, not because I expect it to trend. If even a few people read it and see the beauty in the old language that still runs the world, that is enough.

I would like to find more articles on C so feel free to share, thanks

Here is the link for you: https://github.com/little-book-of/c/blob/main/articles/zig-i...

I hope next month I will have more time to write deep dives into the internals of SQLite, PostgreSQL, Redis and maybe curl, all written in C.

Re: Why is Zig so cool?

#368
post #335

Earlier quoted context omitted.

Oh, and I just submitted a link to my article about C. I am pretty sure no one will click it. Articles about C never get much traffic, but that is fine. I wrote it because I care about how things really work, not because I expect it to trend. If even a few people read it and see the beauty in the old language that still runs the world, that is enough.

I would like to find more articles on C so feel free to share, thanks

and my favorites:

   - https://daniel.haxx.se/blog/2025/04/07/writing-c-for-curl/
   - https://www.sqlite.org/whyc.html

Re: Why is Zig so cool?

#369
post #333

Earlier quoted context omitted.

I've learnt this the hard way. The most important thing is to get you to click. Sometimes I'll first iterate over the title before even writing on substack.

I have learned that too. If you write about C, almost no one clicks. It is not new, it is not flashy, and it does not promise easy results. Yet almost everything still runs on it. The quiet parts of computing rarely get attention, even though they keep everything working. I still write about C anyway. It may not trend, but it lasts.

I'm sure I'm not alone - after decades - already knowing far too much about C, so that any article I'm likely to read either I'm like "No, that's wrong and I even understand why you thought that, but it's still wrong" or I just nod along and sigh.

I spent a substantial fraction of my professional career writing C, and I remain interested in WG14 (the language committee) and in several projects written in C though I avoid writing any more of it myself.

The reason it's so widespread is called "Worse is Better" and I believe that has somewhat run its course. If you weren't aware of "Worse is better" a quick Google should find you the original essay on that topic years back.

In contrast when I read an article about say Zig, or Swift, I am more likely to learn something new.

But I can certainly endorse your choice to write about whatever you want - life is too short to try to get a high score somehow.

Re: Why is Zig so cool?

#370

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…

I can see pros and cons. Preventing data being attached to an error forces more clear and precise errors. Whereas lazy devs could just attach all possible data in a giant generic error if they don’t want to think about it.

Id rather have data in a generic error type than no data in a specific error type.

How useful is a file not found error type without data (the filename) when the program is looking for 50 files? Not very.

How useful is a generic error type with '{filename} not found' as generic string data packed in? Quite.

Post reply on HN