3 ms·
Wuffs is cool, but you can get similar results writing normal C library code, compiling it into a .wasm binary via Clang, and then running the .wasm binary thro
by jay-barronville 2y ago
Wuffs is cool, but you can get similar results writing normal C library code, compiling it into a .wasm binary via Clang, and then running the .wasm binary through the `wasm2c` tool of the WebAssembly Binary Toolkit [0]. I personally prefer this method, although Wuffs will usually produce faster code.
[0]: https://github.com/WebAssembly/wabt/tree/44837a7236e85c048de3214fd2ae4c37d3a034ce/wasm2c https://github.com/WebAssembly/wabt/tree/44837a7236e85c048de...
- krick 2y agoIt is not obvious to me why this should guarantee safety.
- jay-barronville 2y ago`wasm2c` fully implements the WebAssembly sandbox execution environment [0][1] and has the passing tests to prove it. To be a bit more specific, the .wasm binary you generate initially already has the WebAssembly semantics baked in (obviously) and `wasm2c` creates a portable C translation of the WebAssembly while also ensuring that the execution environment is sandboxed (e.g., the code traps when attempting out-of-bounds memory accesses). [0]: https://webassembly.org https://webassembly.org [1]: https://github.com/WebAssembly/wabt/issues/2289#issuecomment-1709207053 https://github.com/WebAssembly/wabt/issues/2289#issuecomment...
- eviks 2y agoHow much faster (say, for something like an image codec)
- jay-barronville 2y agoThis might not be what you want to hear (and I might get downvoted for it), but it’s what I consider the best answer: Implement something minimal but useful (and realistic) using both methods and benchmark them yourself. Even if I told you some of the numbers I’ve seen in my experiments and usage, it wouldn’t be wise to trust them or let them taint your opinion.