Remix.run Logo
bernadus_edwin 2 days ago

Why are so many emulators written in C#?

maximilienNoal 13 hours ago | parent | next [-]

I can give a lot of reasons:

* C#/.NET is very popular in Europe and in the USA. Probably elsewhere too.

* Performance is great, and greater every November. Especially with Spans, structs for performance critical code (they use the stack and not the heap = less GC pressure), and a recent version of the .NET Runtime. Dynamic PGO (that is profile guided optimization by the .NET JIT at runtime) helps also devirtualize a lot of calls, and all we had to benefit from it was move to .NET 8. Can't wait for .NET 10 !

* Since 2016 (.NET Core) .NET is cross platform and open-source (well minus the link between the .NET debugger and the language server), and the overall SDK (the dotnet CLI tool for example) is absolutely great to work with.

* Using native libs or native memory (there are two pointers in the Spice86 applications, and one is on 'reverse: it is managed memory for the native library to use with the fixed keyword for the time of the call)

* Productivity with VS/Rider for writing/debugging .NET code is through the roof! And the docs are very comprehensive.

* Personnaly, I work with .NET daily, and reverse engineering Dune was hard enough. There's alreasdy a new language in there to understand, and that's x86 real mode ASM written by French devs pressured by time to market, and not very concerned with sane calling conventions...

throw-qqqqq 2 days ago | parent | prev | next [-]

I don’t think the language is necessarily chosen for the project. I think C# is just a main stream language that a lot of people know.

sixothree 2 days ago | parent | prev [-]

My guess is portability, then obviously performance.

edit: actually there is a specific answer for this particular project - "We had to rewrite the project in C# to add automated code generation (java doesn't have the goto keyword, making automated ASM translation challenging)". There you are.

anyfoo a day ago | parent [-]

I mean, that's more or less the reason why it isn't Java, not why it's ultimately C#. My guess is that Java is just what they're most comfortable with, with C# being similar enough but avoiding specific limitations in that case.

genewitch a day ago | parent | next [-]

Wasn't C# essentially microsoft throwing their hat in the ring against Oracle and to show off how cool this .net stuff is?

I dabbled in both at around the same time a long time ago for console apps and visual studio's autocomplete / assist / library fetch etc made it easier than Java to get working in but...

Its been so long I forget the origin stories sometimes.

maximilienNoal 39 minutes ago | parent [-]

.NET began its life as Microsoft's Java (the platform) along with C# being a mix between Java, C++, and Pascal.

Considering the timing (early 2000s), one can't help but think that it was in response to the legal actions from Sun Microsystems over their usage of the JVM in Windows.

"OK, I'll make my own Java language, with properties and an integrated DSL for queries!"

sixothree a day ago | parent | prev [-]

I think my question is why not choose c# for this? What’s the apprehension here if any?