← All stories
● Covered by 1 source · 1 reportMedium impact1 neutral

NetWasm Compiler Produces Smaller WebAssembly Binaries for C# Than Rust

🔄 Updated 17d ago
New to BrevFeed? We gather this story from every outlet covering it into one summary — ranked by real-world impact, not just the latest headline — so you never miss what matters. What is BrevFeed? →

Key points

  • NetWasm compiles C# directly to WebAssembly without desktop CLR or Mono.
  • NetWasm produces 47,895-byte WASI components for a 'print-42' workload.
  • Rust's equivalent output is 53,635 bytes, making NetWasm 10.7% smaller.
  • NetWasm includes a precise garbage collector and runtime in its size.

NetWasm Achieves Smaller WASM Output

NetWasm, an independent compiler and runtime for .NET, now generates smaller WebAssembly (WASM) binaries for C# applications compared to Rust. For a specific 'print-42' workload, NetWasm produces a 47,895-byte WASI Preview 2 component. This figure includes its runtime and a precise Compact garbage collector.

In comparison, Rust 1.95.0, using a size-oriented profile, generates a 53,635-byte component for the same workload. This makes NetWasm's output 10.7% smaller in raw size and 19.5% smaller when compressed with Brotli-11.

Compiler and Build Process Details

NetWasm is an independent compiler, CoreLib, runtime, and SDK that directly compiles C# and .NET CIL to WebAssembly. It does not include the desktop CLR, Mono, dotnet.js, or application DLLs in production builds. The reported size for NetWasm is from its default Release publish of a template application.

Rust's comparison figure uses Cargo's documented size settings, including opt-level = "z", LTO, one codegen unit, panic = "abort", and stripped symbols. Binaryen's wasm-opt is integrated into NetWasm's compiler pipeline, running in every ordinary build without additional installation or enabling. For Rust's wasm32-wasip2 output, applying wasm-opt requires manual extraction, optimization, and re-encoding of the component.

Performance Benchmarks

Beyond size, NetWasm also demonstrates faster allocation and garbage-collection benchmarks compared to Mono AOT. These tests were conducted on an Apple M1 Max using Wasmtime 49.0.3, with results verified against desktop .NET. NetWasmGC also showed lower execution times than desktop .NET 11's JIT for two out of three workloads.

Implications for WebAssembly Development

This development provides C# developers with a more efficient option for deploying applications to WebAssembly and WASI environments, particularly where binary size is a critical factor. While both C# and Rust can achieve even smaller sizes by foregoing standard libraries or garbage collectors, NetWasm's current results represent out-of-the-box build configurations.

✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →

The daily brief

One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.

One email a day. Unsubscribe in one click, any time.

Today's brief

Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.

~4 min · 3 stories · Nov 07

▶ Play today's brief Listen on Spotify

New every morning, and the back catalogue is archived by date.

Reporting from

NetWasm, an independent compiler for .NET, now generates WebAssembly binaries that are smaller than those produced by Rust for a comparable workload. For a 'print-42' workload, NetWasm's output is 47,895 bytes compared to Rust's 53,635 bytes, including a precise garbage collector and runtime. This development offers C# developers a more compact deployment option for WebAssembly and WASI applications.