Live data from Hacker News

Zig 0.11

ziglang.org

21–30 of 193 posts

Re: Zig 0.11

#21
post #5

What are the use cases for zig? The website says general purpose and tool chain but people who have used it, what it excels at?

My understanding is that Zig has all of the power and modernity of Rust, without the strictness and borrow checker. Unlike Rust, it also has powerful compile-time evaluation and custom allocators, and probably more improvements I'm not familiar with (in Rust you can effectively emulate custom allocators, but you have to rewrite every allocating structure to use them; or you can use nightly, but most third-party libra…

>My understanding is that Zig has all of the power and modernity of Rust, without the strictness and borrow checker.

This is an oxymoron :) The strictness and borrow checker are part of the power and modernity of Rust.

But even apart from that, Rust has automatic value-based destructors (destructor follows the value as it's moved across scopes and is only called in the final scope), whereas Zig only has scope-based destructors (defer) and you need to remember to write them and ensure they're called exactly once per value. Rust has properly composable Option/Result monads, whereas Zig has special-cased ! and ? which don't compose (no Option of Option or Result of Result) but do benefit from nice built-in syntax due to their special-cased-ness. Rust has typed errors whereas Zig only has integers, though again that allows Zig to have much simpler syntax for defining arbitary error sets which would require defining a combinatorial explosion of enums in Rust.

Of course from Zig's point-of-view these are features, not deficiences, which is completely understandable given what kind of language it wants to be. And the other advantages you listed like comptime (Rust's const-eval is very constrained and has been WIP for ages) and custom allocator support from day 1 (the way Rust is bolting it on will make most existing code unusable with custom allocators, including parts of Rust's own standard library) are indeed good advantages. Zig also has very nice syntax unification - generic types are type constructor functions fn(type) -> type, modules are structs, etc.

I hope that one day we'll have a language that combines the best of Rust's strictness and Zig's comptime and syntax.

Re: Zig 0.11

#23
Zig is not memory safe and therefore at risk, just like C/C++, of future government legislation that outlaws the use of memory unsafe languages for some or all projects. The risk of such legislation is not insignificant: https://www.itpro.com/development/programming-languages/3694...

Personally I do not see the point of building an entirely new language and ecosystem that does not fully address this issue.

Re: Zig 0.11

#24
post #19

Earlier quoted context omitted.

My understanding is that Zig has all of the power and modernity of Rust, without the strictness and borrow checker. Unlike Rust, it also has powerful compile-time evaluation and custom allocators, and probably more improvements I'm not familiar with (in Rust you can effectively emulate custom allocators, but you have to rewrite every allocating structure to use them; or you can use nightly, but most third-party libra…

Also none of the common knowledge around traditional data-structures and algorithms work with Rust anyways. One needs to dance like a ballerina with their hands and feet tied.

“Linked lists are hard” is not “none of the common knowledge around traditional data-structures and algorithms work”.

Re: Zig 0.11

#25
post #7

Anybody here who is using zig on daily basis?

Most days. Just switched to linux to access latest version and features, especially loving the new 'packed struct(u32)' for some low level SoC work (Register representation). I get compile errors if I miscount the bits, and I managed to get some type safety, and not a single 'shift', 'and' or 'or' sign in sight!

Looks like I'll be porting to 0.11.1 as soon as the documentation is in place... I hope they slow down soon, already feels complete. The WASM support is amazing, much smaller outputs than the other options I tried (Java & Go). Great work team!

Re: Zig 0.11

#27
post #5

What are the use cases for zig? The website says general purpose and tool chain but people who have used it, what it excels at?

Bun, a JavaScript runtime (uses WebKit as an engine I believe) is written in Zig. They seem to be doing alright: https://bun.sh/

It uses JavaScriptCore, which was written for Safari. It's supposedly faster than V8, but harder to work with.

Re: Zig 0.11

#28

Zig is not memory safe and therefore at risk, just like C/C++, of future government legislation that outlaws the use of memory unsafe languages for some or all projects. The risk of such legislation is not insignificant: https://www.itpro.com/development/programming-languages/3694... Personally I do not see the point of building an entirely new language and ecosystem that does not fully address this issue.

That totally misses the point of quality software. What good is memory safety if you medical device crashes because of an out of memory error?

What I'm trying to say: There are use cases where areas of safety are required other than memory safety.

Re: Zig 0.11

#29

Zig is not memory safe and therefore at risk, just like C/C++, of future government legislation that outlaws the use of memory unsafe languages for some or all projects. The risk of such legislation is not insignificant: https://www.itpro.com/development/programming-languages/3694... Personally I do not see the point of building an entirely new language and ecosystem that does not fully address this issue.

seriously?

"The National Security Agency (NSA) has recommended only using 'memory safe' languages, like C#, Go, Java, Ruby, Rust, and Swift, in order to avoid exploitable memory-based vulnerabilities."

Post reply on HN