logoalt Hacker News

vlovich123 • yesterday at 4:50 PM • 3 replies • view on HN

Zig makes you choose either safe or fast, not both. With Rust you can get both (generally).


Replies

senderista • yesterday at 6:09 PM

Part of the safety you get with Rust is runtime bounds checking, which is equivalent to Zig in "safe" mode.

➕ show 3 replies
Zambyte • yesterday at 5:14 PM

Zig makes you choose that at build time. You can use safe builds for development to catch bugs, and fast builds for release. You can even use safe builds in of the release, and optimize hot paths with fast builds.

In practice, projects written in Zig very much can choose both.

➕ show 2 replies
audunw • yesterday at 6:56 PM

That’s not entirely true. There’s a third choice. You can go the TigerBeetle route (TigerStyle). Zig is extremely well suited for software where you just avoid dynamic memory allocation all together. It’s extremely fast, very effective and arguably very safe. But not suitable for all applications obviously.

There’s also another caveat that there’s an effort to build in build time static memory safety checks in a way that’s more general than Rusts borrow checker, through a kind of plug in system rather than forced into the language. It’s not part of mainline Zig yet but this seems to be the direction Andrew wants to go.

https://github.com/ityonemo/clr