logoalt Hacker News

theolivenbaum • today at 4:53 AM • 4 replies • view on HN

At the risk of being one of those people shouting "but why not language X?", I'd suggest giving modern C# a serious look. Given the background in C++ and Java, it should feel fairly familiar, while being arguably much more expressive than either and offering excellent language and runtime support for writing allocation-free code.

We've recently ported two large projects to C#, one from Java and another from C++, and seen performance improvements ranging from 30% to 300% faster, largely by focusing on eliminating allocations rather than doing anything particularly clever algorithmically.


Replies

Zambyte • today at 5:07 AM

> largely by focusing on eliminating allocations rather than doing anything particularly clever algorithmically.

Did rewriting it in C# make this easier, or did rewriting make this easier?

➕ show 1 reply
giancarlostoro • today at 4:54 AM

Outside of .NET itself, C# is one of those rare things Microsoft got disgustingly correct. It's entire runtime is cross-platform and MIT licensed.

➕ show 4 replies
keyle • today at 5:47 AM

I'd claim this is the rewrite done by people that know what they're doing that is responsible for most of the gains vs. C#'s compiler to magically make things run faster.

Sure the C# compiler is great and mature; and .NET Jit probably great too. But these massive gains can only be explained by "do less stoopid stuff".

➕ show 1 reply
HackerThemAll • today at 11:51 AM

If I was in charge of Java applications, I'd rewrite them all to C#, Rust, Zig, or even Golang which I don't praise, even if that meant for them to be slower than the original Java, only to escape the Oracle hell.