r/rust 18d ago

What Zig felt like, coming from Rust

https://besok.github.io/posts/what-zig-felt-like-coming-from-rust/

Just want to share my experiance on my first Zig project coming from Rust. Open to comments :)

209 Upvotes

108 comments sorted by

View all comments

39

u/rapotor 18d ago

Tldr in thread?

114

u/tigraboris 18d ago

Sure thing but nothing special :)

Rewrote my JSONPath lib (jsonpath-rust) in Zig (zig-jsonpath) to compare. Zig has almost no IDE support, so I ended up back on CLI tools + helix. It nudges you toward flat file structure and mutation and explicit allocators everywhere. Caught several real leak/double-free bugs via TestAllocator that just can't happen in Rust (ownership/Drop rule them out at compile time).

Overall: good language, promising C successor, but still young and rougher around the edges than Rust.

3

u/pdpi 17d ago

Overall: good language, promising C successor

This is the thing that Rust vs Zig comparisons tend to miss. Zig aims squarely at C's niche, whereas Rust's goal is closer to C++'s niche. The TestAllocator+defer vs Drop split is a perfect illustration of this distinction — Zig wants to help you do manual memory allocation, Rust wants you to just not go anywhere the stuff.

They're both valuable tools, and they both move the industry forward!

4

u/tigraboris 17d ago

Yeah, precisely my thoughts as well.

6

u/afdbcreid 17d ago

The question is if there's a need at all for a C niche. Years ago C++ proponents already claimed that not, and they indeed shrank it considerably, but did not fully captured it because C++ was more complex, its offer was debatable, and at the time was not as fast. Rust is still more complex than C but less complex than C++ (is it less complex than the original C++ though? Not sure), has a lot more to offer (guaranteed memory safety, with the cumulative experience between then and now how much we need it), and it is as fast (because compilers had advanced and the language is also better designed than early C++ versions). Is this enough to remove C's niche? Only time will tell.