HeadlinesBriefing HeadlinesBriefing.com

NetWasm: C# to Small Standalone Wasm with WASI

Hacker News •
×

NetWasm is an independent .NET compiler, core library, runtime and SDK that compiles C# and .NET CIL directly to WebAssembly. Unlike other approaches, it does not carry the desktop CLR, Mono, dotnet.js or application DLLs into production, so the resulting modules stay small and standalone.

In a measured comparison on the same print-42 workload, NetWasm with its precise Compact garbage collector produced a 47,895-byte WASI Preview 2 Component. A Rust 1.95.0 build tuned for size came in at 53,635 bytes. That is 10.7% smaller raw and 19.5% smaller with Brotli-11. The NetWasm figure reflects its default Release publish, while the Rust build added Cargo's documented size settings. Binaryen's wasm-opt runs inside NetWasm's pipeline with nothing extra to install.

On allocation and garbage-collection benchmarks, NetWasm also ran faster than Mono AOT, compiled from the same C# source and run under Wasmtime. Full transaction time dropped 26%, retained object graph time fell 38%, and UI churn time fell 40%. The figures are medians of 15 runs on an Apple M1 Max, with each run checked against desktop .NET's result.

The 46.7 KiB baseline is not a limit. NetWasm supports C# 15, JavaScript modules, Web Workers, static .a interop, WIT and WASI P2 components, expression trees, HTTP, JSON, XML and Regex libraries, and wasm64. It can build, run, publish and test projects through the ordinary dotnet CLI.

Source: Hacker News · Summarized by HeadlinesBriefing