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.
This is an entirely different toolchain from the official .NET one, which is kind of the point of the post, which is experimental, but intended to for production, not for beating benchmarks.
Rust also builds a pretty small binary, which is cool. This isn't really meant to be a 'C# is better than Rust' post, but more pointing out that Blazor (which is the official MS implementation) builds huge binaries; often >10MB, which is a real problem. This fixes that.
That's because Blazor runs on top of Mono not .NET proper if you're using WASM for Blazor, but you can also do server-rendered Blazor and all of that becomes moot.
TFA did [0] the most important stuff for minimizing Rust binaries: release mode, LTO, strip, and abort on panic. But there is a lot more you can do if you really care about Rust binary size [1]: remove location details, purge the debug formatters, rebuild the standard library for size, abort with no error message at all, and many more.
I love when C gets to use non standard freestanding extensions, Rust a no std, is game on, yet when other languages do similar approaches, it doesn't count, it isn't the same language.
I think the complaint has less to do with language toolchains/extensions and more that the post processing performed on the C# output via Binaryen is not unique to the toolchain. It's analogous to comparing the toolchain outputs while zipping one output but not the other.
In both cases, you cannot simply take a random ISO C, ISO C++ or Rust crates code and hope it will work without a single code change in such environment.
IIRC no_std is a per-crate attribute and does not actually forbid use of std, so I think there's a decent chance you can use random Rust crates without changing them.
That being said, I do think it would have been nice if the author had chosen a more interesting benchmark, but alas...
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.
It's for in-browser, security and portability, generally not worth it performance.
A lot of edge cases they'd rather run WASM then a JS or Python VM, it has nicer containerization characteristics. But even with those key cases - it's not necessarily a core, critical technology.
WASM is 'always on the horizon' as being important.
If we had in 2015 what we had today, there might have been a bit of a breakthrough.
> Unless you are building a web version of autocad or premiere,
Yes, but that's the use case. I don't think you'll be able to find someone respected saying "yes we should use this for all use cases regardless of what you're doing". At the other end, htmx is completely fine.
Not necessarily true (especially with the new Zig Io interface), a vanilla Rust Hello World compiles to a 40 KBytes WASI blob, while a vanilla Zig Hello World compiles to 45 KBytes. Both are in the same ballpark. The vanilla C Hello World on the other hand comes out at around 4 KBytes (with the caveat that the compiler is free to replace a non-formatting printf with a direct puts call).
C# is an odd one. It's surprisingly flexible, but then oddly lacking in other areas. Quite productive, but also quite inconsistent and uncomposable.
Once you've tried a better type system (Rust), it's difficult to go back to C#. People jump through all kinds of hoops to get good performance out of it, and they're mostly able to.
Things I dearly miss from Rust when I'm using C#:
- Associated types in interfaces. (IEnumerable should not be forced to return a type-erased = heap allocated IEnumerator instance.)
- Move-only structs. (Currently, every type with value semantics is trivially copyable, even ref structs.)
"IEnumerable should not be forced to return a type-erased = heap allocated IEnumerator instance."
Foreach loops use compile-time duck typing, so if you don't intend to use your enumerable in LINQ then both the enumerable and enumerator don't need to implement any interfaces.
This optimisation covers only one common use case, but that's the way of things in C# land.
IEnumerators can also be value types So no heap allocation, just stack.
slightly off topic but a lot of things in .NET actually use compile time duct typing. like how async works To make your own task, you don't add an interface to it. You just implement a single method.
I’m aware. I would consider the fact that LINQ has caveats a failure of language design - it’s so convenient, but you just can’t use it for performance-sensitive stuff.
Meanwhile, iterators in Rust frequently outperform manual loops.
>- Associated types in interfaces. (IEnumerable should not be forced to return a type-erased = heap allocated IEnumerator instance.)
Its not but if you call from the interface and not the implementation, it has to box because that's the contract. If you for each over a List<T> and not IEnumerable you get a stack allocated value type IEnumerator.
Devirtualization as a (JIT) compile-time optimization is possible in an increasing number of common cases, and I can think of few cases where I'd choose to explicitly consume a non-generic IEnumerable over a non-type-erased IEnumerable<T>.
Optimizations like that is not a sound basis for an architecture, though.
Like, I get that it’s “fine” for a lot of things, but it’s very not fine in situations where you really need to guarantee that a particular operation doesn’t, say, trigger GC, like in a video game.
C# is often like Java but without taking a wrong turn when it came to type-erased generics, the generics are uncomplicated enough even if slightly less powerful than what you get with the full instantiation of C++.
C++ was severely lacking before reflection came along in 26, I'm actually writing some new reflection based libraries and it's mostly a joy and quite capable.
But C++ has so many outrightly dangerous semantics when it comes to writing secure code, the coping of pointing to realtime systems,etc as another security "dimension" doesn't hold when Rust,etc exist today.
C# is good in that it's "easy" yet the performance profile of the features allows optimized code to run far closer to C++/rust/etc in performance compared to Java,etc. (that said, a wast majority is probably running like Java due to programmer patterns, but not needing to drop down to another language when it's needed feels good).
I don't know... I feel like to many C++ templates are hell and C#/Java style generics the sweet spot you want in the actual language.
If you want to do insane meta programming, you should look into Roslyn generators. It's like they added a robust code gen system to the language (even though its a compile stack feature). You basically get the full power of templates and macros but you get to use the target language (C#) instead of a bolted on macro or template language.
Generators are a bit awkward, but definitely workable and essential to the viability of native AOT.
More generally, the fact that the C# compiler is implemented as library with easy support for runtime code generation is also a powerful feature that I've found to be incredibly useful in a variety of expected and unexpected ways.
That's probably the very reason it's arguably not the best language ever created. It has way too large surface area, getting close to C++ levels.
Sure, it's a valid language design, but it's also a negative in "understandability of each line of code", and thus maintainability, and even stuff like tooling, verification.
Yes I think it's a bit underrated. The problem I find is that no one writes C# libraries that actually do anything (e.g. even basic linear algebra is pretty crap compared to python) and that the JIT is a pointless hindrance but the experience of using the stack is pretty good.
> The problem I find is that no one writes C# libraries that actually do anything
Yes, because when you think about it, why should they?
MS has showed many times how unreliable and even user-hostile they can be, so the community at large is very wary of their ecosystem in spite of real advancements.
I agree completely regarding libraries, C# has never had the "libraries for everything", especially open source ones. The better libraries have moved to ( or always have been ) licensed too which doesn't help that impression.
I'd like to hear more about your issue with the JIT and where do you find it a hindrance?
I've had a few benchmarks lately that performed better under JIT than AOT compilation, and while that isn't always the case, the JIT, especially on dotnet 10, performs very well.
No, but when used in application areas where languages like C++ are the obvious alternatives, it has always had very good integration with native code and platform technologies, and in recent history both C# and the .NET ecosystem have been very focused on performance and platform support.
Put another way, "100% pure .NET" was never a goal in the same way it was in the Java world, but I never saw this as holding it back any more than the reliance on native code holds back languages like Python, because both have very good integration stories.
My only complaint is the lack of cross-platform support for C++/CLI, as it was a very useful tool for integrating with libraries that lack a non-C++ API.
The JIT adds basically nothing to the language other than complexity and also forces a boundary between dotnet and it's peers that I think hobbles it via harder interop.
The performance in theory can be slightly better in some niches but my point is simply that it's a huge chunk of complexity for not much gain.
I mean, I lead an initiative to move numerically heavy microservices from c# to numerical python in my previous job (that was initially a windows shop but absorbed a linux based r&d company) because c# was so limiting. But details on that don't really fit into a HN comment.
C# indeed does not have a catch-all ecosystem. But for some domains (servers, UI are a mess but also pretty good, CLI is plausible), it has a very good support. Like Java but nicer (this is subjective) and faster (this is not).
> even basic linear algebra is pretty crap compared to python
I wouldn't qualify that with "even". Numerical stuff like that is one of Python's most well-developed niches, and Python's numerical ecosystem is the benchmark everything else needs to be compared against.
For most projects, a GC'd language is just fine. C#/F# are great languages and I use them for almost everything that doesn't have extreme real-time constraints.
How so? Practically everything that should be async, can be, and in a straightforward fashion. Biggest pain point was the reliance on generated code that complicated debugging and potentially reduced performance, but this is being addressed in upcoming .NET releases.
It just doesnt generally work how I would expect it to work until you learn the details of how to make it work how you expect. Especially as you get into RX it gets really confusing about which execution context you should be on. And execution contexts in mobile land are pretty convoluted to setup IMO.
So yes "async" is easy, but "multithreaded/parallel" is a lot more error prone and explicit.
EDIT: I should also note I havent been in the space for a few years so Im not fully current on how it looks today
That is the saddest part: there is already a fantastic green thread concurrency for dotnet: hopac. F# then got Task {} and people kind of left hopac behind.
ConcurrentML really brought dotnet's concurrency story into the 1990s.
C# async is great. One of the best implementations of cooperative multi threading you can get, IMO.
Greenthreads or what have you are not a replacement if you want to do things like have a UI thread or bind to a native thread for interop. But you _can_ with async/await.
Slightly off topic it is just so bizarre how often Claude uses this turn of phase. It’s almost seems forced here. Anthropic has to be hard coding it to do this.
Not literally (because they're not deterministic), but the RL process can push some behaviors so hard they become deeply ingrained and you can't remove them without more post training.
That's effectively hardcoded if the model is closed source and you're a customer. The only thing you can maybe do with it is put complex jailbreak style prompts in every conversation and that's not really practical.
Shoutout to the [wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen) maintainers who do an awesome job of allowing Rust to be compiled to WASM smoothly. I built an [eigenvalue solver](https://abstractnonsense.xyz/blog/2025-12-31-eigenvalue-solv...) in Rust for an interactive component for my blog, and it was super smooth going. Felt like magic! I've noticed that the binary sizes can blow up a bit by including libraries, but if you're careful I think the binaries are pretty small, tbh.
88 comments
[ 0.16 ms ] story [ 10.5 ms ] threadSince 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.
[1]: https://www.reddit.com/r/dotnet/comments/1x7wsgb/rust_just_l...
Rust also builds a pretty small binary, which is cool. This isn't really meant to be a 'C# is better than Rust' post, but more pointing out that Blazor (which is the official MS implementation) builds huge binaries; often >10MB, which is a real problem. This fixes that.
[0]: https://github.com/zion-sati/NetWasm/blob/main/docs/size-and...
[1]: https://github.com/johnthagen/min-sized-rust
That being said, I do think it would have been nice if the author had chosen a more interesting benchmark, but alas...
Unless you are building a web version of autocad or premiere, I don't see the point of engaging with this technology.
A lot of edge cases they'd rather run WASM then a JS or Python VM, it has nicer containerization characteristics. But even with those key cases - it's not necessarily a core, critical technology.
WASM is 'always on the horizon' as being important.
If we had in 2015 what we had today, there might have been a bit of a breakthrough.
Yes, but that's the use case. I don't think you'll be able to find someone respected saying "yes we should use this for all use cases regardless of what you're doing". At the other end, htmx is completely fine.
If you care about WASM performance, size and memory usage, Zig is a much better candidate.
Good tooling, modern language features (C# 15 has the long awaited unions, closed hierarchies), great debugging experience, etc.
Once you've tried a better type system (Rust), it's difficult to go back to C#. People jump through all kinds of hoops to get good performance out of it, and they're mostly able to.
Things I dearly miss from Rust when I'm using C#:
- Associated types in interfaces. (IEnumerable should not be forced to return a type-erased = heap allocated IEnumerator instance.)
- Move-only structs. (Currently, every type with value semantics is trivially copyable, even ref structs.)
Foreach loops use compile-time duck typing, so if you don't intend to use your enumerable in LINQ then both the enumerable and enumerator don't need to implement any interfaces.
This optimisation covers only one common use case, but that's the way of things in C# land.
slightly off topic but a lot of things in .NET actually use compile time duct typing. like how async works To make your own task, you don't add an interface to it. You just implement a single method.
Meanwhile, iterators in Rust frequently outperform manual loops.
Its not but if you call from the interface and not the implementation, it has to box because that's the contract. If you for each over a List<T> and not IEnumerable you get a stack allocated value type IEnumerator.
Like, I get that it’s “fine” for a lot of things, but it’s very not fine in situations where you really need to guarantee that a particular operation doesn’t, say, trigger GC, like in a video game.
Associated types: https://github.com/dotnet/csharplang/issues/8712
Ownership: https://github.com/agocke/csharplang/blob/ownership/proposal...
C# is often like Java but without taking a wrong turn when it came to type-erased generics, the generics are uncomplicated enough even if slightly less powerful than what you get with the full instantiation of C++.
C++ was severely lacking before reflection came along in 26, I'm actually writing some new reflection based libraries and it's mostly a joy and quite capable.
But C++ has so many outrightly dangerous semantics when it comes to writing secure code, the coping of pointing to realtime systems,etc as another security "dimension" doesn't hold when Rust,etc exist today.
C# is good in that it's "easy" yet the performance profile of the features allows optimized code to run far closer to C++/rust/etc in performance compared to Java,etc. (that said, a wast majority is probably running like Java due to programmer patterns, but not needing to drop down to another language when it's needed feels good).
If you want to do insane meta programming, you should look into Roslyn generators. It's like they added a robust code gen system to the language (even though its a compile stack feature). You basically get the full power of templates and macros but you get to use the target language (C#) instead of a bolted on macro or template language.
More generally, the fact that the C# compiler is implemented as library with easy support for runtime code generation is also a powerful feature that I've found to be incredibly useful in a variety of expected and unexpected ways.
Sure, it's a valid language design, but it's also a negative in "understandability of each line of code", and thus maintainability, and even stuff like tooling, verification.
If you are doing greenfield, you can also make compilation much stricter with Roslyn analyzers and neutralize some of the bullet points here:
https://yannickloth.github.io/independentvariation/software/...
Yes, because when you think about it, why should they?
MS has showed many times how unreliable and even user-hostile they can be, so the community at large is very wary of their ecosystem in spite of real advancements.
I'd like to hear more about your issue with the JIT and where do you find it a hindrance?
I've had a few benchmarks lately that performed better under JIT than AOT compilation, and while that isn't always the case, the JIT, especially on dotnet 10, performs very well.
Put another way, "100% pure .NET" was never a goal in the same way it was in the Java world, but I never saw this as holding it back any more than the reliance on native code holds back languages like Python, because both have very good integration stories.
My only complaint is the lack of cross-platform support for C++/CLI, as it was a very useful tool for integrating with libraries that lack a non-C++ API.
The performance in theory can be slightly better in some niches but my point is simply that it's a huge chunk of complexity for not much gain.
https://numerics.net
https://numerics.mathdotnet.com
https://am.angouri.org
C# sweet spot is really web APIs (and all variants thereof), IMO.
I wouldn't qualify that with "even". Numerical stuff like that is one of Python's most well-developed niches, and Python's numerical ecosystem is the benchmark everything else needs to be compared against.
Rust would be too expensive Engineering wise even with AI today.
So yes "async" is easy, but "multithreaded/parallel" is a lot more error prone and explicit.
EDIT: I should also note I havent been in the space for a few years so Im not fully current on how it looks today
ConcurrentML really brought dotnet's concurrency story into the 1990s.
Greenthreads or what have you are not a replacement if you want to do things like have a UI thread or bind to a native thread for interop. But you _can_ with async/await.
You still get interop with C# and .NET but the syntax and language is superior IMO. If only Ms would invest some resources into it.
what does this even mean
That's effectively hardcoded if the model is closed source and you're a customer. The only thing you can maybe do with it is put complex jailbreak style prompts in every conversation and that's not really practical.
Is this intended primarily for offloading CPU-intense calculations, or sharing code with a C# backend?
Otherwise, what's the intended story for UI? Do all that in JavaScript?