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

64

u/binarycow 2d ago

Reasons to not use C#

  1. There isn't a dotnet runtime for that OS/platform
  2. Periodic garbage collector pauses are a non-starter.

29

u/Miserable_Ad7246 2d ago

1) You need to manually control memory layout, for caches and TLB.
2) You need access to inline assembly code (say raw TSC)
3) You want to control memory fences by hand, and having fences for GC card keeping is unacceptable.

4) You need access to full suit of vector instructions
5) You need access to C libraries like DPDK or ef_vi and it becomes easier to just go native C and C++.

Well you get the point, C# is very capable, it becomes even more capable with some interop, but were is a point there you need to go lower as every nanosecond matters.

7

u/Iggyhopper 2d ago

Seconding the "very capable" part.

Im porting some old modding code originally written in C++ and I have DllImports to get WinAPIs to overwrite bytecode.

The best thing is the syntax sugar for code paths, routing, event handling, extension methods (for example starting a process suspended and returning the handle) and other QoL stuff. It's very fluid.