| ▲ | JuniperMesos 4 hours ago |
| > It's not memory safe like Rust is, but it comes with constructs that make it simple to build largely memory safe programs. Right, this is the specific important thing that Rust does that Zig doesn't (with the caveat that Rust includes the `unsafe` mechanism - as a marked, non-default option - specifically to allow for necessary low-level memory manipulation that can't be checked for correctness by the compiler). Being able to guarantee that something can't happen is more valuable than making it simple to do something correctly most of the time. |
|
| ▲ | sgt 3 hours ago | parent | next [-] |
| Sure but there's this belief in the Rust community that it's not responsible anymore to write software that isn't memory safe on the same level as Rust. So Zig would fail that, but then you could also consider C++ unsuitable for production software - and we know it clearly is still suitable. I predict Zig will just become more and more popular (and with better, although not as complete- memory safety), and be applied to mission critical infra. |
| |
| ▲ | pjmlp 3 hours ago | parent [-] | | If we ignore recent movents in govermental cybersecurity agencies, and big tech to move away from unsafe programming languages, as much as technically possible. Introducing a language with the same safety as Modula-2 or Object Pascal, would make sense in the 1990's, nowadays with improved type systems making the transition from academia into mainstream, we (the industry) know better. It is not only Rust, it is Linear Haskell, OCaml effects, Swift 6 ownership model, Ada/SPARK, Chapel,.... | | |
| ▲ | sgt 2 hours ago | parent [-] | | Of those listed, I'd bet Swift (having had experience with it) is the most pleasant to work with. I just hope it takes off on the systems and backend side at some point. |
|
|
|
| ▲ | dns_snek 3 hours ago | parent | prev [-] |
| It's not that simple though, Zig has equivalent spatial memory safety which prevents issues that are pretty consistently among (or at) the top of the list for most dangerous vulnerability classes. And while I don't have enough experience with Rust to claim this first hand, my understanding is that writing correct unsafe Rust code is at least an order of magnitude harder than writing correct Zig code due to all of the properties/invariants that you have to preserve. So it comes with serious drawbacks, it's not just a quick "opt out of the safety for a bit" switch. > Being able to guarantee that something can't happen is more valuable than making it simple to do something correctly most of the time. Of course, all other things being equal, but they're not. |
| |
| ▲ | goku12 30 minutes ago | parent | next [-] | | > And while I don't have enough experience with Rust to claim this first hand, my understanding is that writing correct unsafe Rust code is at least an order of magnitude harder than writing correct Zig code due to all of the properties/invariants that you have to preserve. How do you make such boldly dismissive assertions if you don't have enough experience with Rust? You are talking as if these invariants are some sort of requirements/constraints that the language imposes on the programmer. They're not. It's a well-known guideline/paradigm meant to contain any memory safety bugs within the unsafe blocks. Most of the invariants are specific to the problem at hand, and not to the programming language. They are conditions that must be met in any language - C and Zig are no exceptions. Failure to adhere to them will land you in trouble, no matter what sort of safety your language guarantees. They are often talked about in the context of Rust because the ones related to memory-unsafe operations can be tackled and managed within the small unsafe blocks, instead of being sprawling it throughout the code base. > So it comes with serious drawbacks, it's not just a quick "opt out of the safety for a bit" switch. Rust is not the ultimate solution to every problem in the world. But this sort of exaggeration and hyperbole is misleading and doesn't help anyone choose any better. | |
| ▲ | ViewTrick1002 27 minutes ago | parent | prev [-] | | I would compare the recent Rust Android post [1], where they have a 5000x lower memory vulnerability rate compared to traditional C/C++ with the number of segfaults found in Bun. [2] In my opinion Zig does not move the needle on real safety when the codebase becomes sufficiently complex. [1]: https://security.googleblog.com/2025/11/rust-in-android-move... [2]: https://github.com/oven-sh/bun/issues?q=segfault%20OR%20segm... |
|