3 ms·
Does Rust code ends with minimalistic wasm? I was astonished to see how nice C code compiles into wasm. It was absolutely minimal, no extra unnecessary stuff (a
by vbezhenar 6y ago
Does Rust code ends with minimalistic wasm? I was astonished to see how nice C code compiles into wasm. It was absolutely minimal, no extra unnecessary stuff (at least for some examples I tried). I definitely would use C for wasm generation, but I did not try Rust. I would really hate to see something like pulling half of standard library for some innocent code resulting in tens or even hundreds of kilobytes of wasm bytecode.
- willglynn 6y agoI can't speak to the general case, but there's no `libc` compatibility cruft in my app. None of my dependencies try to talk to the operating system, and the Rust I wrote in this project uses `js-sys` and `web-sys` directly. If you're minimizing binary sizes, the biggest thing to avoid is `std::fmt`. This requires a little planning but is still quite achievable. #[no_std] crates are always safe to pick, and most of the popular std-dependent crates can be used too though you might need to toggle some features off.
- kryptiskt 6y agoHere is a blogpost demonstrating how small wasm compiled from Rust can be: Making really tiny WebAssembly graphics demos (http://cliffle.com/blog/bare-metal-wasm/ http://cliffle.com/blog/bare-metal-wasm/)