4 ms·
Package management in Zig is more manual than Rust, involving fetching the package URL using the CLI, then importing the module in your build script. This has i
by stratts 1y ago
Package management in Zig is more manual than Rust, involving fetching the package URL using the CLI, then importing the module in your build script. This has its upsides - you can depend on arbitrary archives, so lots of Zig packages of C libraries are just a build script with a dependency on a unmodified tarball release. But obviously it's a little trickier for beginners.
SDL3 has both a native Zig wrapper: https://github.com/Gota7/zig-sdl3 https://github.com/Gota7/zig-sdl3
And a more basic repackaging on the C library/API: https://github.com/castholm/SDL https://github.com/castholm/SDL
For QuickJS, the only option is the C API: https://github.com/allyourcodebase/quickjs-ng https://github.com/allyourcodebase/quickjs-ng
Zig makes it really easy to use C packages directly like this, though Zig's types are much more strict so you'll inevitably be doing a lot of casting when interacting with the API
- LAC-Tech 1y agoIt's also worth pointing out that the Zig std library covers a lot more than the rust one. No need for things like rustix, rand, hashbrown, and a few others I always have to add whenever I do rust stuff.
- nindalf 1y agoYou add hashbrown as an explicit dependency? The standard library HashMap is a re-export of hashbrown. Doesn’t it work for you?
- LAC-Tech 1y agohuh, does it? I always add it so I can make non-deterministic hashmaps in rust. oh and you need one more one for the hashing function I think. But I did not know hashmap re-exported hashbrown, thanks.
- nindalf 1y agoYep, they’re the same since Rust 1.36 (Jul 2019) - https://blog.rust-lang.org/2019/07/04/Rust-1.36.0/ https://blog.rust-lang.org/2019/07/04/Rust-1.36.0/
- LAC-Tech 1y agohttps://doc.rust-lang.org/std/?search=hashbrown https://doc.rust-lang.org/std/?search=hashbrown looks like there's no way to access it, outside of hashmap. Though maybe you just need the third party hasher and you can call with_hasher. IDK man there's a lot going on with rust.
- nindalf 1y agoYes that’s exactly it. If speed is a priority and the input is trusted, change the hasher to something faster like ahash. The ahash crate makes this easy.
- vlovich123 1y agoCan’t speak for the op but there’s a number of high performance interfaces that avoid redundant computations that are only available directly from hashbrown.
- eknkc 1y agoIt is pretty easy to interface stuff like QuickJS C API. I had a POC here from last year: https://github.com/eknkc/zquickjs https://github.com/eknkc/zquickjs Even this is pretty usable, handling value conversions and such thanks to comptime. (Take a look at the tests here: https://github.com/eknkc/zquickjs/blob/master/src/root.zig https://github.com/eknkc/zquickjs/blob/master/src/root.zig)