Live data from Hacker News

Why is Zig so cool?

nilostolte.github.io

451–460 of 527 posts

Re: Why is Zig so cool?

#451

Earlier quoted context omitted.

If the error rarely happens then passing error data shouldn't affect performance in visible way. If the error occurs in common path then it's designed wrongly. I agree that in special states like OOM passing error data with allocation is not ok.

Error data being returned instead of just error codes doesn't require allocation at all, and never would, unless the specific unions that you're returning require as much. Zig already has tagged unions with a tag field and associated payload, that is exactly what you would return. The overhead isn't remarkably worse than the cost of modifying the value someone passed in to "Fill this in in case of errors" (which is w…

For example , if error data contains string, if it directly point to input string it won't require allocation, but will have memory safety issue if error is passed to outer scope where input string is deallocated. Many errors copy string to make it usable in outer scope.

Re: Why is Zig so cool?

#452
post #449

Earlier quoted context omitted.

If you have an example of what you're talking about, I'd like to see it.

An example of Zig not having generics, interfaces, and macros? I don't understand.

@pron If all you mean is there is more syntax to D than to zig to achieve same/similar thing then you may be a bit aggresive on how you communicate it.

Re: Why is Zig so cool?

#453
post #193

Earlier quoted context omitted.

When I read "I can easily say that Zig is not only a new programming language, but it’s a totally new way to write programs" I expected to see something as shocking as LISP/Smalltalk/Realtalk/EVE/FORTH/Prolog... A whole new paradigm, a whole new way to program. Or at least a new concept like the pure functionalism of Haskell, or Prototyping like in Lua/JS/Io. And I was so damn shocked how I must have missed something…

Dev celebs makes blogposts and videos on how Zig is awesome and unique, so the herd repeats.

Same can be said about other programming languages. Therefore the comment of yours has zero value…

Re: Why is Zig so cool?

#454

Earlier quoted context omitted.

The standard models are pretty bad a zig right now since the language is so new and changes so fast. The entire language spec is available in one html file though so you can have a little better success feeding that for context.

> The entire language spec is available in one html file though so you can have a little better success feeding that for context. This is what I've started doing for every library I use. I go to their Github, download their docs, and drop the whole thing into my project. Then whenever the AI gets confused, I say "consult docs/somelib/"

that's what context7 mcp is for!

Re: Why is Zig so cool?

#456
post #120

> Probably the most incredible virtue of Zig compiler is its ability to compile C code. This associated with the ability to cross-compile code to be run in another architecture, different than the machine where it is was originally compiled, is already something quite different and unique. Isn't cross compilation very, very ordinary? Inline C is cool, like C has inline ASM (for the target arch). But cross-compiling?…

If you install Zig, you can now generate executables for virtually any target with just a CLI argument specifying the target, regardless of what machine you installed it on. Nothing else does that--cross compilation generally requires compiling the compiler to target a different architecture.

No, languages like Go and Rust have supported cross-compilation out-of-the-box since before Zig existed.

Re: Why is Zig so cool?

#457
post #39

> Probably the most incredible virtue of Zig compiler is its ability to compile C code. This associated with the ability to cross-compile code to be run in another architecture, different than the machine where it is was originally compiled, is already something quite different and unique. Isn't cross compilation very, very ordinary? Inline C is cool, like C has inline ASM (for the target arch). But cross-compiling?…

> Isn't cross compilation very, very ordinary? Working cross compilation out of the box any-to-any still isn't.

It is for every major compiled language released since 2010.

Re: Why is Zig so cool?

#458

Earlier quoted context omitted.

Destructors aren't just good. They are one of the most important innovations in programming, since they reduce boilerplate and prevent many bugs. Developing a language without them means introducing more bugs which could be avoided.

It violates one of zigs principle of no hidden control flow

If exceptions count as hidden control flow because suddenly a function call can jump to a `catch` block, then defer absolutely counts as hidden control flow because suddenly the end of your function jumps to a `defer` block defined at an arbitrary point higher up. If Zig wanted to be consistent with its own philosophy, it would require some sort of keyword at the end of every scope to indicate that a defer was happening (and require multiple uses of the keyword to indicate multiple defers).

Re: Why is Zig so cool?

#459

Earlier quoted context omitted.

Dev celebs makes blogposts and videos on how Zig is awesome and unique, so the herd repeats.

Same can be said about other programming languages. Therefore the comment of yours has zero value…

Nah, there are many languages ignored or even despised by those dev celebs.

> yours has zero value

Yours didn't bring much as well, so I suppose value isn't strictly required.

Re: Why is Zig so cool?

#460
post #355

I love systems programming language and have worked on the Ada language for a long time. I find Zig to be incredibly underwhelming. Absolutely nothing about it is new or novel, the closest being comptime which is not actually new. Also highly subjective but the syntax hurts my eyes. So I’m kind of interested by an answer to the question this articles fails to answer. Why do you guys find Zig so cool ?

It’s hard to do something that is truly novel these days. Though I’d argue that Zigs upcoming approach to Async IO is indeed novel on its own. I haven’t seen anything like it in an imperative language. What’s important is the integration of various ideas, and the nuances of their implementation. Walter Bright brings up D comptime in every Zig post. I’ve used D. Yet I find Zigs comptime to be more useful and innovativ…

Scala did async io in a very similar way over a decade ago except it was far more ergonomic, in my opinion, because the IO object was implicit. I am not convinced by either scala or zig that it is the best approach.
Post reply on HN