C# now compiles to smaller Wasm than Rust
C# now beats Rust on WASM size
NetWasm, an independent compiler that turns C# and .NET CIL directly into standalone WebAssembly, produces a 47,798-byte WASI Preview 2 component for a print-42 workload, including its runtime and precise garbage collector. Rust 1.95.0 with a size-oriented profile comes in at 53,635 bytes. The project also reports beating Mono AOT on allocation and GC benchmarks and being roughly 320 times smaller than a Blazor WebAssembly build.
This is a new .NET platform, not desktop .NET squeezed into a Wasm sandbox. That boundary is what makes native-Wasm-sized C# possible.
- sondr3
It's a bit of an unfair comparison, the benchmarked C# code here is also post-processed which none of the other targets are. See this comment[1] on reddit where the author announced this on the /r/dotnet subreddit, Rust can go much, much lower. The title is misleading at best and a lie at worst, this is great but saying it beats Rust is a far cry from the truth except for the very narrow benchmark made to showcase this tool.
[1]: https://www.reddit.com/r/dotnet/comments/1x7wsgb/rust_just_l...
- bob1029
I never understood the appeal of wasm outside special performance cases. We never once considered moving from Blazor server side to the wasm mode. Not one time in 5+ years did it ever come up. The whole idea turned out to be a huge distracting waste of engineering talent. Instead of chasing this idealistic wasm pipeline and struggling with weird websocket transports, we could have been writing boring old cshtml and JavaScript on top of stateless HTTP.
Unless you are building a web version of autocad or premiere, I don't see the point of engaging with this technology.
- weinzierl
This is s bit of an unfair comparison, isn't it?
Since WASM ships with a garbage collector that C# can use while Rust does all the memory management itself, of course it will be bigger.
EDIT: Reading OP more thoroughly I think I'm wrong. Apparently in the compared versions, the C# version ships a runtime with garbage collector.