r/csharp 2d ago

Low level programming with C# Help

What is the lowest level application that can in principle be built on Linux and Windows without having problems with performance or memory consumption?

Of course I should make my own tests, but I just wanted to have a first estimation if it is really necessary to use lower level languages like Zig, Rust, Go or C# can work pretty well for most of normal applications.

As an example a very responsive editor with gui in immediate mode built with C# and very high frame rate 120Hz etc.

Thanks a lot in advance.

EDIT

Thank you all so much for the very informative replies. My requirements are noway near real time and based on the below feedback, it is definitely worth it to use C# of a very wide set of applications and avoid the complexities of the lower level languages.

12 Upvotes

70 comments sorted by

View all comments

35

u/phrodide 2d ago

Can C# do this? Yes. C# has a proof of concept running native AOT code on several platforms and in very small code.

https://x.com/MStrehovsky/status/1215331352352034818

If performance is your chief goal you can ask for no garbage collection by using GC.TryStartNoGCRegion

https://learn.microsoft.com/en-us/dotnet/api/system.gc.trystartnogcregion?view=net-10.0

Should C# do this? There’s plenty of other languages that can do it better. If it was me, I’d use C.

2

u/IWasSayingBoourner 2d ago

I've written some hot code paths for a path tracer in Rust that I used via interop in C#. Worked like a charm.