Comment by deevus

1 month ago

I am currently contracted 3 days a week writing Zig. I can't say much because NDA, but I just love working with Zig almost every day. I think for the right projects, it is such a great choice for mission critical software.

You get the added benefit of being able to easily consume C libraries without much fuss. The fuss is in navigating the C APIs of decades old libraries that we all still depend on every day.

Do tell us sometime when you can in the future. It's always interesting to hear what Zig people are doing because they do some very weird stuff.

They wouldn't be using Zig otherwise. :)

I write a fair bit of rust/c for my day job. Do you find zig easier than the ffi interface in Rust?

  • I maintain auto-generated Rust and Zig bindings for my C libraries (along with Odin-, Nim-, C3-, D- and Jai-bindings), and it's a difference like night and day (with Zig being near-perfect and Rust being near-worst-case - at least among the listed languages).

  • > Do you find zig easier than the ffi interface in Rust?

    Yes, but it's mostly cultural.

    Rust folks have a nasty habit of trying to "Rust-ify" bindings. And then proceed to only do the easy 80% of the job. So now you wind up debugging an incomplete set of bindings with strange abstractions and the wrapped library.

    Zig folks suck in the header file and deal with the library as-is. That's less pretty, but it's also less complicated.

  • I've somehow avoided Rust, so I can only comment on what I see in the documentation.

    In Zig, you can just import a C header. And as long as you have configured the source location in your `build.zig` file, off you go. Zig automatically generates bindings for you. Import the header and start coding.

    This is all thanks to Zig's `translate-c` utility that is used under the hood.

    Rust by contrast has a lot more steps required, including hand writing the function bindings.