Live data from Hacker News

Why is Zig so cool?

nilostolte.github.io

381–390 of 527 posts

Re: Why is Zig so cool?

#381
post #377

Earlier quoted context omitted.

What I got was: - pointers to bitfields - checked bitshifts - small ints like u4 - imperative array initialization blocks - test code blocks - equivalent of debugger; keyword from js - some vague stuff about being able to do at compile time The rest is pretty generic

I had to dig farther on the compile time execution stuff. It's actually pretty cool-looking. Recommend digging into it. I don't know that it's a killer enough feature to draw me away from Rust's guarantees, but it is interesting.

It is difficult to overstate how useful compile-time execution is in practice. I can't imagine using a systems language without it now. The term "modern C++" largely denotes when compile-time execution was added to that language.

I would love to see Rust get compile-time execution that is as capable as Zig or C++20.

Re: Why is Zig so cool?

#382

Earlier quoted context omitted.

People are working on this. std.zon is generally considered to be a good example of how to handle errors and diagnostics, though it's an area of active exploration. The plan is to eventually collect all the good patterns people have come up with and (1) publish them in a collection, and (2) update std to actually use them.

> how to handle errors and diagnostics, though it's an area of active exploration I am flabbergasted and exasperated by this sentiment. Zig is over 9 years old at this point. This feels this same kind of circular arguments from Golang "defenders" about generics and error handling.

When will we see Zig 1.0?

Re: Why is Zig so cool?

#384
post #187

Earlier quoted context omitted.

D has had compile time function execution since 2007 or so. https://dlang.org/spec/function.html#interpretation It doesn't need a keyword to trigger it. Any expression that is a const-expression in the grammar triggers it.

Yes and D's comptime is much more fun, IMHO than Zig's! Yet everyone talks about Zig's comptime as if it were unique or new.

[deleted]

Re: Why is Zig so cool?

#385
I think what sets Zig apart from other low level languages is how easy it is to navigate a Zig source code. I was discouraged at the time (things probably changed now) when the best source for documentation was "read the Zig's source code". But I was impressed by how easy it was to find what I needed.

while this is due to Zig maintainers' code quality, I think a large contributing factor is the choice of syntax. As an exercise, try navigating a C, C++ and any other language source code without an IDE or LSP. things like:

- "Where did that function come from?"

- "What and where is this type?"

what do you have to do to find that out? due to the flexible ways you can declare things in C, it may take you a lot of steps to find these information. even in search, a variable and a function can share the same prefix due to the return type placement. hence why some people prefer function return types in a separate line.

Even with languages like Rust for example, finding if a type in a function parameters is an enum or struct and finding its definition can require multiple steps like search "enum Foo" or "struct Foo", in Zig i can search "const Foo" and i will immediately know what it is.

while i do hope that C gets defer and constexpr functions in the next standard or maybe better generics or enums, Zig syntax is much better to work with in my opinion.

Re: Why is Zig so cool?

#387
post #350
post #322

Earlier quoted context omitted.

I think even in the year of our lord 2016 there's room for a language with safe defaults but seamless interoperability with existing unsafe code. It's certainly an improvement on the status quo and provides an alternative to rewriting the world in Rust or a GC language.

Except Zig defaults could be found on the year of our Lord in 1976, 1978, 1983 and 1986. Exercise from other posts of mine which languages those might be.

Sure, but Zig is bringing those to users and making headlines on HN. I think that’s generally a good thing. Bringing the best of prior languages together in a new package

Re: Why is Zig so cool?

#388

I think what sets Zig apart from other low level languages is how easy it is to navigate a Zig source code. I was discouraged at the time (things probably changed now) when the best source for documentation was "read the Zig's source code". But I was impressed by how easy it was to find what I needed. while this is due to Zig maintainers' code quality, I think a large contributing factor is the choice of syntax. As a…

I also hope that WG14 eventually adopts successful features from Zig, such as comptime, and reduces the use of ugly macros and _Generic.

Re: Why is Zig so cool?

#389
post #367

Earlier quoted context omitted.

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.

thanks, i enjoyed reading it (though a bit lengthy).

what gets me personally is what you describe at https://github.com/little-book-of/c/blob/main/articles/zig-i... - zig is made to feel easy and modern for people who don't know any better, and it does this well. But as soon as you actually need to do complex stuff, it gets in the way moreso than C and it's current environment/ecosystem will.

And to be fair, as much as I enjoyed writing in C in my younger years - I only use C when I actually need C. And asm when I actually need asm. Most of my code now uses higher level languages - this puts zig into such a niche.. it feels like golang to me: the cool language that isn't really solving as much of a need as you'd think.

Re: Why is Zig so cool?

#390

Earlier quoted context omitted.

>Perhaps the author has very narrow experience in programming languages. I got that impression as well. Xi's impressed about types being optional because they can be inferred. That's ... hardly a novelty ...

>Only the first and third part are compulsory in Zig, which is kind of puzzling, coming from Java or C. Funny they mention Java that has got type inference few years now. Even C got a weaker version of C++'s auto in C23.

One of the many things I don't like about C++ is that auto isn't type inference but instead C++ has type "deduction" which is a little different, in some cases a type will be "deduced" even though what you wrote was ambiguous and you may have wanted a different type.
Post reply on HN