Skip to main content

Command Palette

Search for a command to run...

.NET deserves a more honest look than it gets.

Updated
•2 min read•View as Markdown
.NET deserves a more honest look than it gets.

Rust gets the headlines in blockchain infrastructure. But .NET deserves a more honest look than it gets.

Nethermind, one of the main Ethereum execution clients, is written in C#. Neo’s core node and smart contract toolchain are C#. Nethereum is the main Ethereum library for .NET developers. Here’s the technical case for the platform, including where it falls short.

Latency. .NET has a garbage collector, so tail latency is something you manage on purpose. Server GC with concurrent collection, GCLatencyMode.SustainedLowLatency, and GC.TryStartNoGCRegion around critical sections all help.

The bigger win is allocating less. Spanlt;Tgt;, stackalloc, ArrayPoollt;Tgt; and ref struct keep hot paths off the heap.

Safety. In safe code, managed memory rules out use-after-free and buffer overruns, and nullable reference types flag likely null dereferences at compile time. For money, use decimal for fiat and BigInteger for 256-bit on-chain amounts, never double.

Concurrency. This is where Rust wins. Its compiler rules out data races, and C# doesn’t. You design for it with immutable record types, Channellt;Tgt; pipelines, Interlocked and Parallel.ForEachAsync. Parallel transaction execution works the same way in any language: declare which state each transaction touches, then run the non-conflicting ones concurrently.

WASM. Blazor WebAssembly runs the .NET runtime in the browser. It ships the runtime with your code, so for tiny contract modules, Rust is the better fit.

One caveat applies to every language. C# arithmetic is unchecked by default, so an int at int.MaxValue plus one wraps to a negative number with no exception. Set lt;CheckForOverflowUnderflowgt;truelt;/CheckForOverflowUnderflowgt; or wrap critical math in checked { }.

Memory safety isn’t protocol correctness. The security work is still yours.

Which part of your stack would you rewrite in another language first, and what would you refuse to touch?

6 views