9 ms·
Zig fits pretty naturally here too. We've got ~19 WebGPU examples[1] which use Dawn natively (no browser support yet), and we build it using Zig's build system
by slimsag 3y ago
Zig fits pretty naturally here too. We've got ~19 WebGPU examples[1] which use Dawn natively (no browser support yet), and we build it using Zig's build system so it 'just works' out of the box with zero fuss as long as you grab a recent Zig version[2]. No messing with cmake/ninja/depot_tools/etc.
WASM support in Zig, Rust, and C++ is also not equal. C++ prefers Emscripten which reimplements parts of popular libraries like SDL, for me personally that feels a bit weird as I don't want my compiler implementing my libraries / changing how they behave. Rust I believe generally avoids emscripten(?), but Zig for sure lets me target WASM natively and compile C/C++ code to it using the LLVM backend and soon the custom Zig compiler backend.
[1] https://github.com/hexops/mach-examples https://github.com/hexops/mach-examples
[2] https://github.com/hexops/mach#supported-zig-version https://github.com/hexops/mach#supported-zig-version
- flohofwoe 3y ago> ...Emscripten which reimplements parts of popular libraries like SDL AFAIK those library headers are just historical artifacts from a time when those library didn't have official Emscripten ports, and which today are only reluctantly maintained if at all. Emscripten's web API wrappers make a lot of sense though, and the other unique feature is the 'inline Javascript' support (so you don't need to maintain the Javascript glue code in separate .js source files).
- slimsag 3y agointeresting; I didn't realize libraries were adding official emscripten ports using the emscripten APIs. That's definitely a level up in my eyes, then.
- flohofwoe 3y agoAt least SDL2 has 'proper' Emscripten support: https://wiki.libsdl.org/SDL2/README/emscripten https://wiki.libsdl.org/SDL2/README/emscripten My own cross-platform headers too: https://github.com/floooh/sokol https://github.com/floooh/sokol ...there are also auto-generated Zig bindings btw ;) https://github.com/floooh/sokol-zig https://github.com/floooh/sokol-zig