logoalt Hacker News

bernadus_edwinlast Thursday at 5:44 PM3 repliesview on HN

Why are so many emulators written in C#?


Replies

maximilienNoalyesterday at 7:50 PM

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-qqqqqlast Thursday at 6:04 PM

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.

sixothreelast Thursday at 5:59 PM

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.

show 1 reply