logoalt Hacker News

raincole • today at 4:45 PM • 5 replies • view on HN

C# already provides many tools for your performance-critical code though. You can use pointers in unsafe. You can allocate unmanaged memory with Marshal. You can avoid copy with Span. You can even manually vectorise with Vector.IsHardwareAccelerated and such.

You can also distribute apps without .NET runtime with NativeAOT.

I'm sure there are people who want a C# without GC, but for me it's just... sufficient enough.


Replies

randomNumber7 • today at 6:17 PM

> I'm sure there are people who want a C# without GC

There's also C++ and although it is a monstrosity the practical thing would be to use that.

If you want a serious alternative to C++ I don't see it in C# without GC. On the other hand I have seen a lot of C++ code where normal C# would be much better suited.

jeremyjh • today at 7:04 PM

Also people expect when they use a C# compiler that existing programs and libraries written in C# will be usable, but this doesn’t appear to support the same standard library APIs. So why use C# at all instead of a language with an ecosystem that has the properties you want?

➕ show 2 replies
lowbloodsugar • today at 7:32 PM

.NET runtime also has generational GC and escape analysis (so objects can be allocated on the stack if they have a known lifetime). Generational GC essentially give you a super fast bump allocator for short lived objects: faster than malloc.

Even without unsafe we can allocate objects once and just reuse them. But why would you? C# is the go to for interfacing with native code and unmanaged memory. ( C# is way ahead of Java tho JDK 25 is beginning to catch up). I miss C#.

Figure out what parts of your app needs to be “downcoded” and optimize that. Enjoy bump allocators and plentiful libraries for the rest of it.

I wrote graphics applications in C# that used 3GB of memory back when we had to tell XP, at boot, to not use half the 32bit address space for itself. Most of it was in unmanaged space. C# is awesome.

Waraqa • today at 5:14 PM

NativeAOT can't compile for DOS.

➕ show 1 reply
samuelknight • today at 5:28 PM

NativeAOT gets rid of JIT not GC. The language is rich enough that you can avoid making garbage though.