top | item 31468019

(no title)

wpdev_63 | 3 years ago

Found out the other day the nintendo switch emulator ryujinx is written in C#. It's the first I've heard of a performant emulator written with a gc language and it's amazing. It's as fast as its competitor written C++ which goes to show that C# can be just as fast as language without a runtime with minimal gc pauses.

discuss

order

mastax|3 years ago

C# has a lot of performance oreinted features that are rare to find in GC languages. Value types and real Generics, of course, which helped during the dark years when the JVM was clearly better. There's relatively efficient and convenient interop with unmanaged function pointers and other helpers. Ref structs like Span make it easy to efficiently and safely pass around references to buffers rather than copies. In, out, and ref parameters and readonly structs help reduce unnecessary copies in function arguments. The .NET team has been optimizing the standard library using C# SIMD intrinsics. It's a great language for writing convenient code most of the time, and hyper optimizing where it counts.

gavinray|3 years ago

Having done a fair bit of C/C++ interop stuff with C#, I would say this is definitely its standout compared to Java.

The things you mention are huge, along with "UnmanagedCallersOnly", the ability to write structs and mark them as meant to be used in interop code (see "Blittable/Unmanaged Types" proposal that was recently adopted), and the seamless "DllInterop" annotations for pulling in native external methods.

https://devblogs.microsoft.com/dotnet/improvements-in-native...

https://github.com/jkoritzinsky/runtime/blob/a5048c2fe5068e9...

The team that works on the native/interop stuff is top-notch, and they're constantly pushing boundaries and making neat improvements.

I'm more of a JVM guy, but credit is well due here.