Remix.run Logo
Decabytes an hour ago

Here is where I think Zig shines. When you are a high level programmer that needs to drop down to a low level programming language for performance reasons. The issue with doing that as a high level programmer is that you don't do a lot of low level work frequently.

So unless you work in another domain where you do a lot of low level programming, then every time you drop down you will be out of practice. This favors using a simpler low level language, with low friction for integration. Rust and C++ don't handle being used infrequently, but C with it's simpler standard library and syntax fits this nicely. But it doesn't have things you expect for a modern programming language, and it is also has a lot of dangerous footguns that are easy to forget if you are out of practice

In comes Zig. It's low level, comes with it's own toolchain that makes it pleasant to work with, easy to cross compile, has more safety features built in that C, but is not overly complicated. The code tends to be more verbose, but also more straightforward. So it's a perfect language to pair, when you know you won't be able to do everything in a high level language.

For me that's what seals the deal. I'd argue that Odin has a nicer syntax, but there is a reason that tools like cargo-zigbuild^1 exists. The fact projects not related to Zig are willing to ship Zig toolchains to make lives easier is a testament to how seriously Zig takes this.

1. https://crates.io/crates/cargo-zigbuild

jayd16 an hour ago | parent [-]

Looking at it from an existing knowledge base and error checking point of view, I feel like C++ smart pointers or Rust is a better option for someone doing a dangerous low level thing rarely. I'm not sure Zig is really all that favorable a choice in your given scenario.