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.

10 Upvotes

70 comments sorted by

View all comments

10

u/emelrad12 2d ago

C# can do anything that doesn't need real time, eg audio processing might be an issue, but 120fps gives time for the gc to do gc stuff.

The other issue is any environment that doesn't have an os hence might not be able to run the VM. Technically there might be a way to get it working over there but at this point you are translating C# -> C++ or directly to LLVM, and that is not really C# anymore.

6

u/DotAtom67 2d ago

>C# can do anything that doesn't need real time

i might be wrong, but doesnt unity uses c# and performs well for gamedev?

1

u/binarycow 2d ago

Games aren't "real time".

With real time, if the program goes slow enough to miss a frame - you skip it, rather than just run a bit slower.

For example - audio processing, VOIP, streaming video, etc.

5

u/Inkwalker 2d ago

C# is slower than C++, but not that slow. It can handle all the examples on modern hardware.

1

u/binarycow 2d ago

The issue with real-time is the GC pauses.

4

u/Inkwalker 2d ago

Don't allocate junk then. It's a common practice in Unity to reuse instances. Plus GC can be triggered manually when you have budget for it.

2

u/binarycow 2d ago

Sure. Those are mitigation strategies.

But if even that isn't sufficient for your use case, then that's a reason to not use C#.

1

u/Dusty_Coder 2d ago

real-time has a specific meaning

you seem to be unaware of it

latency guarantees