*Stephan Schmidt
- December 2, 2026*
I compiled the same programs from 16 languages to WASM and measured them #
TL;DR: If an agent writes your WASM apps, let it use Rust: in my test of 16 languages Rust matched C’s speed with a 39 KB hello world, while standard Go took 3.3 times as long and shipped 2.4 MB because its runtime and goroutine support come with every program. If it has to be Go, use TinyGo without the scheduler (1.4 times C, but no goroutines), and measure your own app before you rewrite anything, because database waits can hide the difference and Go on the server is still a good choice.
Last year I wrote about why I chose Go over Rust, but for WASM I’d choose the other way round. I had Claude write the same six programs in 16 languages, compiled them to WASM and ran them on one core of my desktop. Go came out last of the languages that have a compiler, its programs need 3.3 times as long as the ones in C (AssemblyScript is right next to it with 3.2), and its hello world is 2.4 MB, of which 249 bytes are my code. C# can run as fast as C, and Kotlin’s hello world is smaller than Rust’s.
I measured this because of a sentence in No Code Review. Fuzz Instead., the essay about AppOS, which is one way to let marketing ship to production and puts every app into a sandbox (I use WASM, but it’s one option of several for the sandbox). I wrote there that you can compile Rust, Go (with TinyGo) and C# to WASM and that JavaScript and Python bring their interpreter along, “so the agent writes the app in the language it writes best”. The only speed I had measured was Rust’s. Naive me would have thought the language would not matter, execution time in WASM is roughly the same, as is the size of the compiled file. Boy was I wrong.
What do you ship with a hello world? #
WASM knows numbers, functions and a block of memory, and everything else your language needs has to be in the file, the garbage collector, the scheduler for goroutines, the code that prints a stack trace, and for Python the whole of Python. The engine that runs the file (Wasmtime on a server, V8 in your browser) gives you none of that, except for garbage collection in newer engines.
In the Amiga days I played opcode puzzle to get as much code as possible into the 1024 bytes of a boot sector (which even made it into a magazine). The hello world in C is 2.6 KB, so two and a half of those boot sectors. The one in Go doesn’t fit on an Amiga floppy with its 880 KB, you’d need three of them.
This is the size next to the run time, with C as 1.0<sup>1</sup>:
| Language | Hello world | Run time |
|---|---|---|
| Zig | 59 KB | 0.9 |
| C | 2.6 KB | 1.0 |
| Rust | 39 KB | 1.0 |
| C# (NetWasm) | 47 KB | 1.0 |
| C# (NativeAOT-LLVM) | 846 KB | 1.3 |
| Go (TinyGo, without goroutines) | 79 KB | 1.4 |
| Swift | 5.6 MB | 1.6 |
| C# (Mono, compiled) | 7.7 MB | 1.7 |
| Java (TeaVM, WASM GC) | 13 KB | 1.8 |
| OCaml (WASM GC) | 41 KB | 1.8 |
| Go (TinyGo) | 284 KB | 1.9 |
| Kotlin (WASM GC) | 12 KB | 2.1 |
| AssemblyScript | 7 KB | 3.2 |
| Go | 2.4 MB | 3.3 |
| C# (Mono, interpreted) | 2.9 MB | 14 |
| Python | 7.9 MB | 30 |
| JavaScript (QuickJS) | 1.4 MB | 39 |
| Ruby | 16.6 MB | 96 |
On a server the 2.4 MB alone cost you little, the engine compiles the file to machine code once (1.9 seconds for Go, 0.05 for Rust) and keeps the result. But when every request gets a fresh sandbox, which is how I do it, every request starts the runtime of the language again. From the new sandbox to the end of hello world it’s 0.03 ms for Rust and 0.48 ms for Go, so a core that does nothing but start Go gets to 2,100 requests per second before any app code runs, but the Rust component I measured for the fuzzing essay did 16,700, including parsing JSON and rendering HTML. (You can keep the sandbox for the next request and only pay for the start once, but then data from one request is still in memory for the next one.) In the browser you pay for the download, 538 KB for Go after Brotli and 13 KB for Rust.
Go’s runtime comes in one piece #
The garbage collector with its allocator is 27% of the code in Go’s hello world, goroutines with the scheduler, the stacks and the channels are 21%, and my main is 0.02%. With println in place of fmt.Println the file is still 1.9 MB, because the linker doesn’t drop the scheduler when a program never starts a goroutine, or the tracing code when nobody traces. The 2.4 MB are stripped with -ldflags="-s -w", but 0.37 MB of the data are tables the garbage collector needs to walk the stacks, so they stay.
Swift ships even more, 5.6 MB, and 81% of its code is the standard library (there’s a function in hello world that prints a vector of 32 numbers for debugging, 36 KB). Swift has a second mode for small devices, Embedded Swift, which gets hello world down to 13 KB, but Go doesn’t have one, unless you count TinyGo.
Why is Go slow in WASM? #
A goroutine has to be able to stop in the middle of a function, because it waits for a channel for example, and go on later. Natively Go switches to another stack, but WASM has no instruction for that (there’s a proposal), so the Go compiler turns every function into a state machine that can leave at every call and come back in at the same place, whether your program uses goroutines or not. This is a method from the binary trees program:
func (n *node) check() int {
if n.l == nil {
return 1
}
return 1 + n.l.check() + n.r.check()
}
The Rust program has the same function, and there it’s 41 WASM instructions (the Rust compiler turns the second call into a loop), but the Go compiler needs 172 for the method above. A call of check is two instructions in Rust, one puts the pointer on the stack and the other one is the call. In Go it’s these sixteen, the comments are mine:
local.get 1
local.get 2
i64.store ;; the argument goes to Go's own stack, in memory
local.get 1
i32.const 8
i32.sub
local.tee 1
global.set 0 ;; move the pointer to that stack
local.get 1
i64.const 374079493
i64.store ;; remember where to go on
i32.const 0
call $main.__node_.check
global.get 0
local.set 1
br_if 5 ;; did check stop in the middle? then stop too
Last year I wrote that goroutines are “surprisingly irrelevant when you write a web app”, a bit like applets in Java (though more useful), the killer feature no one cared about once Java was mainstream. But in WASM you pay for them with every call.
If it has to be Go, take TinyGo, which is a second compiler for Go, and switch off the scheduler with tinygo build -target=wasip1 -opt=2 -scheduler=none. Hello world is 79 KB then, the programs run at 1.4 times C, which is faster than Swift, and JSON goes from 1.08 seconds to 0.64. You lose the go keyword for that<sup>2</sup>.
Why is Kotlin smaller than Rust? #
Kotlin needs a garbage collector as much as Go does, but its hello world is 12 KB and Rust’s is 39 KB (33 KB when you optimize for size). WASM 3.0 comes with garbage collection, WASM GC, where a module declares its objects as structs and arrays and the engine allocates them and cleans up after them, so there’s no garbage collector in the file. Rust doesn’t use the memory management of the engine, so 11 of its 39 KB are malloc (and 8 KB are the code for formatting strings). TeaVM, which compiles Java to WASM, had its own garbage collector up to version 0.13 and uses WASM GC today, so I could measure both. Hello world went from 87 KB to 13, but only 12 of the 87 were the collector with its exceptions and its stack, the rest is mostly library code and data about classes that’s gone too. With a 64 MB heap the programs got a little faster, from 2.1 times C to 1.8, but with the default heap of Wasmtime they got slower, 2.8.
The speed of WASM GC depends on the engine. Wasmtime has it switched on by default since July 2026<sup>3</sup>, the heap starts empty and then the engine collects all the time, so the word count in Java took 2.7 seconds until I gave it 64 MB at the start, and then it took 0.7. V8 has had WASM GC since 2023, and it runs the same Kotlin files about twice as fast as Wasmtime, JSON even 3.3 times (1.39 seconds against 0.42), while C, Rust and Zig gain 12%. In the browser Kotlin is closer to Rust than my table says.
Go can’t use WASM GC, because Go allows pointers into the middle of an object and WASM GC doesn’t have them, so every pointer would need to carry two values. The issue has been open since November 2023 and its milestone is Unplanned<sup>4</sup>. Sad. The .NET team isn’t planning to adopt WASM GC either, for similar reasons<sup>5</sup>.
How does C# get as fast as C? #
It depends on the compiler, the same C# source can be as fast as C or 14 times slower, and hello world can be 25 KB or 7.7 MB. Mono from Microsoft interprets the .NET bytecode, that’s the 14, or compiles it ahead of time, then it’s 1.7 times C, and the 7.7 MB of hello world still contain the interpreter for what can’t be compiled. NativeAOT-LLVM, also from Microsoft but experimental, gets hello world to 846 KB and the programs to 1.3 times C, but each start is 23 ms, because its garbage collector touches 50 MB of memory first.
NetWasm isn’t from Microsoft and is as fast as C, because it allocates an object by moving a pointer, so the binary trees in C# with a garbage collector need about as long as in C with malloc, and because it uses the exceptions WASM has today, while NativeAOT-LLVM only knows the old ones, which Wasmtime refuses, so in my test it checks after every call if there was an exception. For that you have to set O3 and the garbage collector NetWasm in the project file. With the defaults you get the 25 KB hello world and 2 times C, and the binary trees need eight times as long. F# is at 1.06 times C and Visual Basic at 1.17 (yes, I compiled Visual Basic to WASM), but I had to compile both to a .NET assembly first and call it from one line of C#.
I wouldn’t put NetWasm into production yet. The repository is from August 2026, nearly all commits are from one person, the README doesn’t name anyone who runs it in production, your host needs WASI 0.3, and companies with 250 people or $10M revenue pay for the compiler<sup>6</sup>. The README also says NetWasm is more than three times as fast as Mono AOT (the compiled one), but on my programs it was 1.7 times.
What about JavaScript, Python and Ruby? #
They bring their interpreter, so the four programs need 30 (Python), 39 (JavaScript) or 96 (Ruby) times as long as in C, and nbody, which is only math, 100 times in Python and JavaScript and 600 times in Ruby. JavaScript is fast in the browser because of the JIT compiler, but a JIT compiler can’t run inside WASM, because a module isn’t able to create new code while it runs. Ruby has an additional problem with floating point numbers. A 64 bit Ruby hides them inside the pointer, but WASM pointers have 32 bits and there’s no space for that, so 200,000 float operations allocate 200,001 objects (natively it’s one). Python needs 29 ms to start and Ruby 204, but JavaScript starts in 0.07 ms, because Javy (the tool that builds the file) starts QuickJS at build time and stores its memory in the file.
Which language should the agent use? #
I chose Go over Rust because of the compile times, the learning curve and the borrow checker. Two of these were about people, about me and the developers I’d have to hire, and when an agent writes the code, the borrow checker barks at the agent. When I had Claude translate Go projects last winter, Rust worked fine and Zig ended in a doom loop, because Zig had changed its API and Claude kept writing the old one. For this test Claude did write six Zig programs, but they’re short, so Zig may be the fastest in my table, but I’d still not give it to marketing’s agent.
What six small programs don’t tell you #
An app that waits 5 ms for a query doesn’t notice if its own code takes 0.1 or 0.3 ms, and the user doesn’t notice the 0.48 ms Go needs to start, but the core is busy for that time in every request, so you need more of them for the same traffic. I’m not sure how much of this is left in your app, with your libraries and your database, and I’d measure it before I’d rewrite anything.
I also didn’t tune Go. With GOGC=400 it gets from 3.3 to 3.0 times C, and AssemblyScript is last, but then the binary trees need 90 MB. Kotlin, Java and OCaml got a heap of 64 MB in my tests, which helps them a lot (Kotlin would be at 3.0 without it). And none of this is about Go on a server, natively the same Go programs need 1 to 2.5 times as long as C, and I’d still pick Go there because it's cheap to maintain.
When WASM gets stack switching and Go uses it, the state machines go away and I need to measure again. Until then I’d change the sentence in the fuzzing essay, the agent should write the app in Rust.
- Wasmtime 51, one core of a Ryzen 9 3900X, a fresh instance for every run, output checked, median of the runs. Run time is the geometric mean of nbody, fannkuch, binary trees and word count, without the time to compile WASM to machine code. The sixth program, JSON, compares libraries more than languages, so it’s not part of the mean (AssemblyScript has no JSON library in the test). Java, Kotlin and OCaml have a 64 MB heap at the start, Java (TeaVM 0.17) is made for a JavaScript host and runs in Wasmtime with a few functions of my own. The .NET compilers were measured on the same day as the rest but later, when the machine was about 10% faster, so they’re compared with a second run of C. Python and Ruby are without debug info and need their standard library in addition (4.7 and 2.9 MB zipped). Elixir (AtomVM, 0.9 MB) isn’t in the table because it finished two of the four programs. ↩︎
- TinyGo, Optimizing binaries :
-scheduler=noneremoves “support for the go keyword and some related features”.↩︎ - Nick Fitzgerald, GC and Exceptions in Wasmtime , July 2026. The team writes that they worked on correctness first and that the speed doesn’t match V8 yet.↩︎
- golang/go#63904 , runtime: implement WASM-GC. Ian Lance Taylor wrote there that pointers would have to become fat pointers.↩︎
- dotnet/runtime#94420 , “at this time we are not planning to adopt it.”↩︎
- NetWasm 0.16. The compiler is free for individuals, open source, education and companies with fewer than 250 employees and less than $10M revenue, the others pay from $149 a month for five developers. What ends up in your WASM file is MIT or Apache licensed.↩︎
About me: Hey, I'm Stephan, I help CTOs with Coaching, with 40+ years of software development and 25+ years of engineering management experience. I've coached and mentored 100+ CTOs and founders in more than 1200 sparring and coaching sessions. I've founded 3 startups. 1 nice exit. I help CTOs and engineering leaders grow, scale their teams, gain clarity, lead with confidence and navigate the challenges of fast-growing companies.
Most of the CTOs I coach didn't know CTO coaching was a thing until they were already drowning. It is a thing - here's what it is.