5 ms·
Maybe easier integration with existing C libraries? They give an example of a tetris clone in Zig. This is how they include GLFW with Zig: https://github.com/a
by quacker 10y ago
Maybe easier integration with existing C libraries?
They give an example of a tetris clone in Zig. This is how they include GLFW with Zig: https://github.com/andrewrk/tetris/blob/master/src/c.zig https://github.com/andrewrk/tetris/blob/master/src/c.zig and all other locations in the project just import this c.zig file.
In contrast in Rust, I think you have to actually declare all the functions you want to use from a C library. For example: https://github.com/PistonDevelopers/glfw-rs/blob/master/src/ffi/mod.rs#L331 https://github.com/PistonDevelopers/glfw-rs/blob/master/src/....
- tomjakubowski 10y agoThere are C library binding generators for Rust which do the boring work for you. It's not perfect, but rust-bindgen was pretty good last time I tried it (~15 months ago): https://github.com/Yamakaky/rust-bindgen https://github.com/Yamakaky/rust-bindgen
- skissane 10y agoWhen a language has built-in support for easy binding to C, that's a positive. When other languages such as Rust offer that feature through external tools, that's not as good, since I need to evaluate which of those external tools to use (when there is more than one), and it is something else to download/install/learn and another step to add to the build process. So it looks to me like Zig handles this better than Rust does (of course, Rust has clear advantages over Zig in other areas: much more mature / widely used, and more advanced memory management.)
- ycombinatorMan 10y agonot nearly as attractive as inline C or direct C imports
- deleted 10y ago[deleted]
- Ygg2 10y agoPfft, pretty sure you could inline C in Rust. No one was brave enough to develop said compiler plugin.
- kbenson 10y agoI think there exists, or work has been done on, a tool to auto generate that data for you. So not quite as simple, but possibly more fine grained control.