Remix.run Logo
▲ raincole 4 hours ago

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.

▲randomNumber7 3 hours ago | parent | next [-]

> 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 2 hours ago | parent | prev | next [-]

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?

▲dragonwriter 41 minutes ago | parent | next [-]

I mean, unless you don’t need any memory to be released during a run, everything needs to be rewritten to use memory management through arenas, which is a whole new memory management paradigm even for most people used to languages which require either manual memory management or highly specific lifetime specifications. So, yeah, no nontrivial existing code is usable even before you consider that none of the libraries supplied by the runtime that most code relies on are available.

▲DANmode an hour ago | parent | prev [-]

Such as?

▲lowbloodsugar an hour ago | parent | prev | next [-]

.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 4 hours ago | parent | prev | next [-]

NativeAOT can't compile for DOS.

▲to11mtm a minute ago | parent | next [-]

I know it's a bit contrived as far as making it work, but doesn't SeeSharpSnake [0] have a DOS compile option?

Hell, I'll be bold and say, if there's a worthwhile AI credit sink, it would be just adding it all properly as a bolt on or similar to NativeAOT.

[0] - https://github.com/MichalStrehovsky/SeeSharpSnake

▲dragonwriter 39 minutes ago | parent | prev | next [-]

Which would be a problem if I needed to write code today and send it back to the 1990s to be run, but I have about as much need to compile to DOS as I need to produce punch cards to load into ENIAC.

▲raincole 4 hours ago | parent | prev [-]

I... guess so? But the last time I had users who use DOS was in my previous life. NativeAOT supports iOS though, which is a reasonable target for the current-life me.

▲samuelknight 4 hours ago | parent | prev [-]

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