Hacker News new | ask | show | jobs
by josephg 794 days ago
Because it’s a good language.

Fast enough for most applications. Memory safe enough. Easy enough to learn. Good enough type system. And it helps that it’s integrated into unity and windows. Also the ecosystem, compiler and IDE support is exceptional.

It’s not perfect. It’s slower than native code. It has a worse type system than rust, Swift and typescript. (Burn the nulls!) And C# needs a runtime - which makes it annoying to deploy on Mac & Linux.

I’d put it as an A tier language.

1 comments

ARC and shared_ptr are net more expensive than GC, in throughput scenarios you will see that C++ often offers no meaningful performance advantage. Also Swift is significantly slower due to upfront ARC cost and defaulting to virtual dispatch in many places, more so than .NET with interface spam (Dynamic PGO takes care of it anyway).

Nulls have stopped being an issue in practical terms since you specify nullability explicitly e.g. string?/string.

C# does not need runtime installed on the host. You can produce JIT or AOT executables which include one. It also needs runtime on Windows just as much (if you don’t include it or host doesn’t have it installed). Only .NET Framework was preinstalled but no one (sane that is) chooses this legacy target for new code.

Do you have some benchmark examples where C# beats the throughput of C++ using shared_ptr?