3 ms·
Interesting that Ryujinx is written in C# - I'm not sure why, but at first thought I'd have expected something like a console emulator (where one would have to
by marksomnian 3y ago
Interesting that Ryujinx is written in C# - I'm not sure why, but at first thought I'd have expected something like a console emulator (where one would have to do "unusual" memory / GPU operations to fully match the quirks of the platform) to be written in C or C++, like Dolphin or PCSX2 (Wii / PS2 emulators) are. Though clearly they can make C# work well for it, and the benefits of working in a managed language are probably worth it.
- jsheard 3y agoIt originally had a very unique approach, it would JIT the emulated instructions into .NET bytecode and then let the .NET runtime JIT that into native code. At some point they switched over to their own bespoke JIT-to-native engine for more control though.
- whizzter 3y agoI'm also using the dynamic code-loading to get free JIT in other projects and quite a few features of .NET relies on that, there are limitations (and for something as dynamic as an emulator I'm not at all surprised that they hit a brick wall at some point). Another benefit of C# is that they continually add features to make the language less susceptible to GC stalls. Compared to Java you have Value types, real generics, ref and out arguments, Span<T> types, stackalloc allocations, unsafe blocks and so on. You can get quite far without allocating anything on the heap and the ergonomics won't be that much worse than even C++ when doing so.
- aftbit 3y agoC# has an unsafe mode if you need it. I've written some low level hardware twiddling code in C# before. It can also be very fast. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/unsafe-code https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
- kminehart 3y agoIt's probably not super important with the switch like it would be with the nintendo 64 or something because it's an ARM cpu.
- neonsunset 3y agoThe YoY performance improvements after going .NET Core 1.1/2.1 up until current .NET 8 have been very significant which allows C# to be the language of choice for writing systems-like performance-sensitive code. It also had quite a rich unsafe API since .NET Framework days which has since then been complimented by safer alternatives which offer similar or better performance namely Span<T>s and then lately struct optimizations which are helped by the fact that C# generics with struct arguments == Rust generics with struct arguments (aka the ones which are not Box<dyn Trait>).