| ▲ | sgt 4 hours ago |
| > and isn't suitable for any of the domains where Rust excels. That's a pretty bold claim since Zig is specifically designed for systems programming, low level stuff, network services, databases (think Tigerbeetle). It's not memory safe like Rust is, but it comes with constructs that make it simple to build largely memory safe programs. |
|
| ▲ | JuniperMesos 4 hours ago | parent | next [-] |
| > 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 34 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 31 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... |
|
|
|
| ▲ | ViewTrick1002 an hour ago | parent | prev | next [-] |
| Given the density of memory issues in the Bun issue tracker I have a hard time squaring the statement that Zig makes it "easy" to build memory safe programs. https://github.com/oven-sh/bun/issues?q=segfault%20OR%20segm... |
|
| ▲ | GuB-42 2 hours ago | parent | prev [-] |
| Rust is not designed for low level system programming / embedded systems like Zig is. It is designed to make a browser and software that share requirements with making a browser. There is some overlap but that's still different. The Zig approach to memory safety is to make everything explicit, it is good in a constrained environment typical of embedded programming. The Rust approach is the opposite, you don't really see what is happening, but there are mechanisms to keep your safe. It is good for complex software with lots of moving parts in an unconstrained environment, like a browser. For a footgun analogy, one will hand you a gun that will never go off unless you aim and pull the trigger, so you can shoot your foot, but no sane person will. It is a good sniper rifle. The Rust gun can go off at any time, even when you don't expect it, but it is designed in such a way that it will never happen when it is pointed at your foot, even if you aim it there. It is a good machine gun. |
| |
| ▲ | Ygg2 2 hours ago | parent [-] | | > Rust is not designed for low level system programming / embedded systems like Zig is. Pray tell, with Rust already being used in kernels, drivers, and embedded what makes Zig better suited for low-level systems? More chance to explode a UB in your hand? For that, there is C. | | |
| ▲ | GuB-42 40 minutes ago | parent [-] | | Great C interop, first class support for cross-compilation, well suited for arena allocators. You can use Rust in kernel/embedded code, you can also use C++ (I did) and even Java! but most prefer to use C, and I think that Zig is a better alternative to C for those in the field. There is still one huge drawback with Zig and that's maturity. Zig is still in beta, and the closest you get to the metal, the more it tends to matter. Hardware projects typically have way longer life cycles and the general philosophy is "if it ain't broke, don't fix it". Rust is not as mature as C by far, there is a reason C is still king, but at least, it is out of beta and is seeing significant production use. I remember when I talk about Zig to the CTO of the embedded branch of my company. His reaction was telling. "I am happy to hear someone mention Zig, it is a very interesting language and it is definitely on my watch list, but not mature enough to invest in it". He was happy that I mentioned Zig because in the company, the higher ups are all about Rust because of the hype, even though we do very little of if BTW, it is still mostly C and C++. And yeah, hype is important, customers heard about Rust as some magical tech that will make the code bug-free, they didn't hear about Zig, so Rust sells better. In the end, they go for C anyways. |
|
|