←back to thread

Things Zig comptime won't do

(matklad.github.io)
458 points JadedBlueEyes | 6 comments | | HN request time: 0s | source | bottom
Show context
no_wizard ◴[] No.43744932[source]
I like the Zig language and tooling. I do wish there was a safety mode that give the same guarantees as Rust, but it’s a huge step above C/C++. I am also extremely impressed with the Zig compiler.

Perhaps the safety is the tradeoff with the comparative ease of using the language compared to Rust, but I’d love the best of both worlds if it were possible

replies(5): >>43744960 #>>43745201 #>>43745418 #>>43745573 #>>43749228 #
1. xedrac ◴[] No.43745201[source]
I like Zig as a replacement for C, but not C++ due to its lack of RAII. Rust on the other hand is a great replacement for C++. I see Zig as filling a small niche where allocation failures are paramount - very constrained embedded devices, etc... Otherwise, I think you just get a lot more with Rust.
replies(2): >>43745255 #>>43745507 #
2. xmorse ◴[] No.43745255[source]
Even better than RAII would be linear types, but it would require a borrow checker to track the lifetimes of objects. Then you would get a compiler error if you forget to call a .destroy() method
replies(1): >>43745597 #
3. rastignack ◴[] No.43745507[source]
Compile times and painful to refactor codebase are rust’s main drawbacks for me though.

It’s totally subjective but I find the language boring to use. For side projects I like having fun thus I picked zig.

To each his own of course.

replies(1): >>43745951 #
4. throwawaymaths ◴[] No.43745597[source]
no you just need analysis with a dependent type system (which linear types are a subset of). it doesn't have to be in the compiler. there was a proof of concept here a few months ago:

https://news.ycombinator.com/item?id=42923829

https://news.ycombinator.com/item?id=43199265

5. nicce ◴[] No.43745951[source]
> refactor codebase are rust’s main drawbacks

Hard disagree about refactoring. Rust is one of the few languages where you can actually do refactoring rather safely without having tons of tests that just exist to catch issues if code changes.

replies(1): >>43746010 #
6. rastignack ◴[] No.43746010{3}[source]
Lifetimes and generic tend to leak so you have to modify your code all around the place when you touch them though.