raincole 1 day 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.

  • Waraqa 1 day ago

    NativeAOT can't compile for DOS.

    • raincole 1 day ago

      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.

    • dragonwriter 1 day ago

      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.

    • to11mtm 1 day ago

      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

  • samuelknight 1 day ago

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

  • randomNumber7 1 day ago

    > 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.

    • DeathArrow 16 hours ago

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

      True, but can't you work with a subset of C++ that you consider sane?

  • jeremyjh 1 day ago

    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?

    • DANmode 1 day ago

      Such as?

      • jeremyjh 22 hours ago

        C++, Rust or Zig

        • DANmode 20 hours ago

          Rust and Zig, in that order, sound good.

          C++ seems out of place, unless you’re making a game and or don’t care about safety.

    • dragonwriter 1 day ago

      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.

  • lowbloodsugar 1 day ago

    .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.

  • a3w 22 hours ago

    Isn’t marshaling about network representation, so the same concept as javas Parcelable tries to solve ?

    • chews 21 hours ago

      sorta.. if you're thinking gRPC and Protobuf, but because they're on the same machine and often in the same process, it's a pointers-wizzeled interface all provided by the layers it was built on... then it just maps types, responses, and their interfaces. P/Invoke is wizardry.

    • raincole 18 hours ago

      In C# (and generally in programming) marshaling is the conversion between your typical memory representation (in C# it's your object) and the other ways (be it C struct, C string, utf8 string, or whatever received from socket.) that's why AllocGlobal is under Marshal. Not saying one should use it though... the only ones sane programmers would touch is probably to handle C structs returned from native code.

      • jasomill 17 hours ago

        System.Marshal is a sort of catch-all for functions used to interact with unmanaged code, including things like Win32 error handling and COM in addtion to type conversion and unsafe memory access in general.

bob1029 1 day ago

The GC is a feature. Not a bug to be eliminated.

GC is not surrendering control. That seems to be HN's #1 bug bear. The sensation that someone or something is taking control away from you. The proper way to frame this is that you can actually focus on the original problem you set out to solve. Risking memory leaks is crazy when it's not something the customer is demanding. Even in gaming I think the GC is fine. There are ways to spread the impact across frames and bound the amount of time spent collecting.

If your clever scheme wouldn't work with a GC-managed heap, it probably won't work with one managed by hand either.

  • andai 1 day ago

    GC is literally surrendering control.

    But it really depends on what you're doing. You can use the wrong tool for a job, but you can also use the right tool. It depends on the job.

    • jayd16 1 day ago

      It's only surrendered control if you refuse to understand it and how to control it.

      • unrented7977 1 day ago

        Exactly. You have a shocking amount of control over the GC if you bother to learn. Surrendering control is a choice the programmer makes by not understanding their tools.

      • lilbigdoot 1 day ago

        There's still limits on that control.

        • unrented7977 1 day ago

          You'll need to be a lot more specific, because C# offers you a lot of control. You can, for example, disable GC and run it manually at runtime. You can exempt objects from GC. You can exempt objects from relocation. You have pointers and unsafe contexts. Frankly I can't think of anything you'd want to do with GC that isn't offered already.

          One does not have to live with the tradeoffs that C#'s default GC makes. One just needs to understand how the GC works and how it is controlled.

      • generichuman 1 day ago

        The (Tracing) Garbage Collector abstraction isn't really designed to be controlled though. You can understand the implementation and write code against that, but at that point, why not switch to something that you can genuinely control?

        I'm not saying manage memory manually. You can switch to a language that is reference counted. Then at least that abstraction guarantees deterministic deallocation.

        That comes with another set of trade-offs such as having to pay attention to atomic reference counts, making sure there's no cycles, maybe even treating some graphs as arenas to avoid chained deallocations, but the abstraction itself is designed to be deterministic and is more easily controlled.

    • nayuki 1 day ago

      Don't fall for the illusion that manual memory is the pinnacle of control. Because raw pointers cannot be moved, you can end up with a lot of external fragmentation - i.e. holes between your allocations. Also, the bookkeeping cost of malloc() and free() are not free, which also means that the latency of calling those functions is unpredictable. There's a reason why embedded developers are very hesitant to use malloc()/free() for hard real-time programs with time and memory constraints.

      And at least with GC, you are guaranteed to surrender the possibility of double-free and use-after-free.

      • worik 22 hours ago

        > Don't fall for the illusion that manual memory is the pinnacle of control.

        That is a False Dichotomy

        • zdragnar 20 hours ago

          Is it? When parent is replying to

          > GC is literally surrendering control.

          it would seem that no GC is in the other direction, literally not surrendering control.

          • deathanatos 20 hours ago

            > Don't fall for the illusion that manual memory is the pinnacle of control.

            Manual memory management is not the only alternative to GC; RAII & smart pointers require, for the overwhelming majority of uses, no more thought than C#'s `new Foo` does, and don't require the concerns about manually free, use-afte-free, etc. that come with "manual memory".

            • jaen 12 hours ago

              Smart pointers ie. reference counting are a (not very good) form of GC...

              Especially in multi-threaded settings, smart pointers perform poorly (compared to GC) due to requiring atomics on hot paths, and the alternative (epochs, hazard pointers, RCU) is orders of magnitude more complicated to get exactly right than just using GC.

              This also explains why historically the most interesting concurrent data structures were first implemented in Java, not C++.

              eg. Java got a decent concurrent hash table WAY before anything else - in 2003 vs. the 2006 initial release of Intel TBB, and the performance was not as good for all use cases. C++ performance did not catch up until ~2017 with the release of folly::ConcurrentHashMap!

  • Jooror 1 day ago

    I think some devs have painful memories of early GCs, compounded by the qualities associated with “corporate” codebases of the time. I would imagine younger programmers are writing more managed code than C and skew towards having no complaints about GCs.

    Agreed that it’s no longer a bottleneck for games; profile—and-optimize approaches are very effective and the tooling has never been better.

  • 999900000999 1 day ago

    Arguably without GC C# becomes a different language. But if you’re really comfortable with C# and can’t handle unexpected lag spikes I can see this being useful.

  • jameshart 1 day ago

    Exactly. The problem People have with GC is not garbage collection per se, it is garbage collection pressure. The solution to which isn’t doing away with the GC, it is managing and controlling allocation.

  • dafelst 1 day ago

    Indeed - even Unreal Engine uses GC for all its internal object management. It's not a language level thing, more a runtime entity thing, but it is there. It simplifies object lifetime management quite a bit.

    To be fair, it is also probably the number one cause of long hitches in poorly optimized UE games, and also the main contributor to class of use-after-free bugs (persisted native pointers and references to objects that weren't properly added to the object graph, though goes away with proper usage of weak object pointers and the like) so it is very much a double-edged-sword.

  • wk_end 1 day ago

    Garbage collection is a feature but it's also a trade-off, like most things in engineering. IMO it's a worthwhile trade-off more often than a lot of people think (though a lot of people don't think enough about it). But there's also times that it's not worthwhile, and we shouldn't pretend otherwise.

    • worik 22 hours ago

      > IMO it's a worthwhile trade-off more often than a lot of people think

      I am one of those people that like non GC'd languages also. The concept of the GC Pause bothers me

      But my preference and "bother" are not business strategies. For most purposes, and in my professional life, garbage collection is a boon.

      For my hobby programming I choose real time domains so I can flex my Rust coding for fun and not pointlessly.

      • WorldMaker 6 hours ago

        Today's GC languages with multi-threaded generational mark and sweep generally don't "GC pause". You can see slow downs if you hit a worst case, like accidentally churning your large object heap and/or long-lived generation too fast, but even then it is rarely a "stop the world" pause but a subtle competition for CPU cycles and memory bus but other parts of your application like network I/O might not even notice.

  • Johanx64 1 day ago

    Arenas, etc is GC done right.

    Or rather GC done explicit.

    You control when and where and how garbage gets collected in various buckets and disposed off.

    Without the performance hit of fully automatic GC.

    > Risking memory leaks is crazy when it's not something the customer is demanding.

    Memory leaks have NEVER been a significant source of bugs.

    Memory corruption has always been the problem (lack of memory safety, ie. operating in perpetual unsafe block), not the memory leaks.

    Memory leaks are relatively trivial to track and account for in comparison.

    • pron 1 day ago

      Generational moving GCs work much like arenas, and they work without the limitations of arenas and without the performance hit of malloc/free. That's not to say arenas aren't very efficient and useful, but few languages make them convenient and composable enough (Zig), and even then they need to be used with care.

      • cogman10 1 day ago

        > and without the performance hit of malloc/free.

        Arenas avoid most of the performance problems of malloc/free.

        I think the bigger problem with arenas and manual management is memory lifetime is very hard to get right, particularly in the context of concurrent operations. It also cuts away algorithms you can do.

        • pron 1 day ago

          > Arenas avoid most of the performance problems of malloc/free.

          Sure, but they're not fully general, which is why you also need malloc/free for things that don't work well in arenas (or write the equivalent of malloc/free on top of arenas, which is what you need to do in Goose: https://github.com/aardappel/goose/blob/master/bench/kostya/...).

          Also, arenas can be an even better fit for languages with good GCs than languages without a GC.

          • cogman10 1 day ago

            > arenas can be an even better fit for languages with good GCs than languages without a GC.

            That's counterintuitive to me. I could see them being useful if you need off heap allocations, but on the heap it seems like they'd tend to be harmful rather than helpful. The only benefit they'd seem to have is forcing the colocation of memory. But they have the big downside of (likely) ending up promoting a bunch of memory into old gen.

            • pron 23 hours ago

              You're talking about arenas that you implement manually in ordinary objects. I'm talking about arenas managed by the language/runtime.

    • jaen 11 hours ago

      Memory leaks and memory corruption are two sides of the same thing.

      They're just symptoms of managing the lifetime of memory incorrectly. Same solution for both - either better (safe) explicit lifetime management or GC.

      Arenas don't fundamentally solve leaks nor corruption.

      (I'm excluding resource leaks from the definition of memory leaks, to not muddy the discussion)

      • Johanx64 9 hours ago

        > Memory leaks and memory corruption are two sides of the same thing.

        > They're just symptoms of managing the lifetime of memory incorrectly

        No, they aren't. They are completely different class of a bug.

        And have little to do with memory lifetime management.

        Memory corruption happens, because certain language(s) make extensive use of unsafe constructs and doesn't have as little as basic built in container types (like friggin arrays or even strings) that do boundschecking by default, so you can overrun buffers and everything - left, right and center. And that's exactly what happens!

        So C and to some extent C++ (with additional hundreds of footguns of all stripes)

        The biggest benefit of languages like C# - more than anything, in addition to overall better ergonomics - is that they are memory safe first and foremost, and not inherently because of GC.

        • jaen 6 hours ago

          You're mixing up (or don't understand the difference between) spatial and temporal memory safety.

          What you're talking about is spatial safety, but just having that does not end memory corruption.

          Not having temporal safety eventually leads to the same outcomes and issues (search the CVE lists for UAF exploits...)

          Temporal safety can only be achieved via GC or explicit safe lifetime management.

  • fortran77 21 hours ago

    Yes! Except for some very specialized real-time applications, GC is fine for most all userland applications. I love C#/F# (or Erlang for massively parallel). It's safe, a wild pointer won't get you, compiles fast, and runs everywhere.

  • nellacross 13 hours ago

    Concerns about GC pauses are real.

    It would be interesting to see an official time-bounded GC feature where you could manually trigger a collection with a specific time budget, such as 5ms. The GC would collect a portion of objects and defer the rest to the next cycle. The runtime could still perform automatic GC pauses.

  • riedel 1 hour ago

    There is other ways to manage heaps that might fit better or not. When building compilers a long time ago, we had tons of issues with stuff dangling around in subgraphs that we did not free. The approach was using obstacks. Seems the 'arenas' used here do a similar thing: simply tear down a whole memory area. Actually it is a bit like writing a GC yourself: if you want to keep structures, you copy them into the new 'heap'. It is not that bad of a strategy depending on what you are programming.

YuechenLi 1 day ago

So... What does this have over using NativeAOT which already exists?

Keep in mind a large portion of time NativeAOT is actually SLOWER than going through RyuJIT with the only definitive benefit being smaller binaries, and it's not like you can't do Span<T> and ref structs in modern C# for manual low level memory control already.

So my question is just... why?

  • MarkSweep 1 day ago

    My view is that this is mostly for demo-scene style programs. The author of bflat, from which this slop is forked, has some examples on their website of a "2kb game for windows" or "4kb game targeting UEFI" (i.e. no operating system).

    https://migeel.sk/blog/2023/12/08/building-bare-metal-bootab...

    I would not want to build a long term project on top of this, as maintaining a fork of the .NET runtime is somewhat labor intensive.

  • andix 23 hours ago

    Much smaller binaries, faster execution. It's basically like C or Rust with C# syntax.

    But that's also the main limitation, it's kind of a worse version of Rust, with very limited memory management and no ecosystem.

    • YuechenLi 22 hours ago

      I would just call it a strictly worse subset of C++ with C# syntax rather than Rust, because this doesn't have Rust's memory safety or exhaustive pattern matching, and arena allocation has its own trade-offs too.

      • reverseblade2 21 hours ago

        C# 15 does have exhaustive pattern matching.

        • YuechenLi 19 hours ago

          Oh, right. Thanks for reminding me, kinda embarrassing since I just implemented Result <T, E> in the new app I'm building with unions.

  • jasomill 13 hours ago

    Referring to Native AOT rather than this:

    If your goal is to distribute small, single-file executables, the size difference can be an order of magnitude.

    The difference in startup time can be similarly significant, which is important in many applications.

    Finally, the introduction of Native AOT has motivated the development of fast compile-time alternatives to many things in both the framework and third-party libraries that traditionally relied on comparatively slow runtime code generation and/or reflection, which benefit AOT and JIT alike.

buybackoff 1 day ago

For C# as is, what I really would appreciate is a frozen GC mode. Not zero GC, similar to Epsilon GC in Java. After initial state loading and forced GC, I would like to be able to apply a SustainedNoGC mode, that just does not even try to collect, no scanning, no pauses at all, it can only allocate. And notifications (an event) after some X bytes allocated, or just a reliable way to monitor the allocated size. The existing modes such as SustainedLowLatency or NoGCRegion are good but not enough. For some low latency workloads it's OK to allocate many GBs and then pause explicitly.

Random forced pauses are the only problem that comes from GC, otherwise it's great for throughput and just a nice feature, as a sibling comment says. No GC languages do not make code magically faster, they still have malloc/free. However, GC is surrendering control over when a program may be paused.

  • ablob 1 day ago

    Can't you just initialize and then do a NoGCRegion? It would give you everything except the monitoring I think.

    • buybackoff 1 day ago

      It does not work the way I described. It is only for short periods and is not a guarantee, and has overheads for repeated calls.

      • jasomill 12 hours ago

        .NET has supported custom garbage collectors for many years, so if you're willing to accept that all heap-allocated objects will live as long as your process, implementing a no-op garbage collector should be a straightforward exercise.

        • buybackoff 8 hours ago

          It's far from straightforward. And I need a special mode, eg during application start it may generate a lot of garbage, I want that collected, but then continue with idle GC. With an option to collect overnight, or when too much is allocated, but in controlled way.

          • WorldMaker 5 hours ago

            This pattern isn't far from what a videogame sometimes needs to run a level: load a lot of data, generate a lot of garbage, try to collect all the garbage after load but before gameplay, then keep the GC from running again.

            In C# you get most of that by calling `GC.Collect()` when you know you've finished loading and should be in a steady state. (I've seen non-games do it after application start as well, though in an enterprise application with full Server GC and plenty of RAM it feels more like a superstitious call than a necessary one.) Then in your "idle state" you can just try to avoid creating garbage. Games often use object pools aggressively, making sure most objects it needs are LOH/Gen2 and a few other "no allocation"/stack allocation-only approaches in the middle of a level.

            You can try to ask the GC nicely with `GC.TryStartNoGCRegion()` during a section of your code but it's not necessarily a good idea and a lot of caveats apply.

            But also, a lot of what you are asking for is sort of already what the default GC is optimized for by being a generational mark-and-sweep GC. It's tuned for bursts like application startup generating a lot of quick garbage that never leaves Gen0 and fast "arena sweeps". It's tuned for eventually reaching an Idle state where most of your objects are long-lived and hanging out in Gen2 and very rarely even checked to be collected.

  • to11mtm 23 hours ago

    TBH, at least in my head, I feel like what it needs more is a 'string-ish type that can be used in a pool'.

    With Pooling/Arenas already semi-established, you can do lots of stuff with pools/arenas. Where the challenge comes, is how much of Corelib (and normal apps) use strings in places, and you can't get around that without a lot of DIY. The "foostring" u8 const conversion helps for some cases but doesn't cover nearly enough cases.

    • buybackoff 22 hours ago

      What about Span<char> over char[]? Or a tiny struct wrapper with the length. Or do you mean some deeper runtime support?

hollowonepl 1 day ago

I’m not sure, the whole point of this language, standard libraries and runtime is built around GC. Nobody from C# world is educated or prepared to manually manage memory. This is just bare metal C++ with a lot of it stripped away and just nicer/cleaner syntax that does not inherit so much from C and POSIX archeology.

Nice POC, especially on MS-DOS but nothing truly relevant in the long run, I’m afraid

  • andai 1 day ago

    I was already sold, you didn't need to sell me harder!

  • jayd16 1 day ago

    What if I told you both Unity and Unreal use C# extensively? Plenty of game devs are familiar with memory management and C#.

    That said, I don't see how this project fits in all that nicely.

    • hollowonepl 1 day ago

      memory management in a .net way. not native without .net and its magical ephemeral generational garbage collector that does the awesome job so people don't need to even think about mutations.

      • twodave 23 hours ago

        This position is about 5 years out of date. Even before we had Span<T> though it was tenuous at best.

  • lowbloodsugar 1 day ago

    I concede your point in general, but there are SWEs who are intimately familiar with GC and memory management. I used to write graphics applications in C#, and games in Unreal, which uses GC and other shenanigans.

    • hollowonepl 1 day ago

      point is this zero c# doesn't have GC and won't release your blocks automatically. that's whole different thing, could be better if there is community that will push that somewhere.. but standard C# developer like you guys (both who commented in the context of game dev and unity) think you manage memory just because you use .net runtime and gc does the rest.

      I commented this one explicitly because that zero c# platform pitched here is just the language syntax you know and then manual new/delete just like in c++

      • lowbloodsugar 1 day ago

        > standard C# developer like you guys

        Thanks. This made me smile. Remember Mike Acton worked on Unity for a while. Look him up. See if he doesn’t care about memory. (I am not Mike).

        • hollowonepl 22 hours ago

          I meant no offense to anybody, when I was working with .NET people most were taking memory management for granted, not mistaking it with memory optimization of course.

  • behindsight 23 hours ago

    when was the last time you used C# in a non-legacy environment?

    I feel like some of the derisive statements you are making is coming from a decade old negative impression of some C# shop in a random town cranking out basic CRUD apps.

andix 23 hours ago

Assuming this is very similar to bflat: it's a cool idea and fun to play with, but not very useful. C# is not designed to run without a GC, existing code usually won't run, because the standard library is missing.

Just using C, Rust, Zig, or whatever is probably nearly always the better option. Those languages are designed to work without GC and provide various well established ways to manage memory.

  • Alifatisk 1 hour ago

    It says on the website "A fork of bflat"

Dwedit 1 day ago

You really don't want to use C# with the "Bflat/Zero" runtime library. Even something very basic like strings is unsupported. It becomes C code with funny syntax that doesn't align well with the language.

I have not yet tested out Beef, but it seems to be more in line with what you'd want from a native C#-like language.

pmkary 17 hours ago

I looked for DLL support and found nothing. The standard library is also different from C#, and you have to manage memory on your own. Sadly I don't get the point. People code in C# for the .NET and its huge library, unless this is not a drop in replacement, you have to port your whole codebase; well then people will write Rust already...

real_faxenoff 22 hours ago

I'm developing a small .NET utility called montab (https://github.com/faxenoff/montab - taskbar with permanent previews for Windows) and have been trying to minimize its size and CPU/GPU usage as much as possible. The result is a 0.88 Mb binary with near-zero system load.

It would seem that Zero C# is the ideal solution for me. But here’s what I’ve actually found out: I’d have to rewrite absolutely everything, and the lack of a garbage collector when constantly working with a bunch of WinAPI calls is a problem with no solution.

I’ve come to realize that this might only be suitable for new applications that don’t use external components.

  • qingcharles 22 hours ago

    Why is GC needed? We always used to have to manage our own memory per app. Track what you use and release it when you're done. I used to write Windows apps using Win32 calls all day long with no GC.

    I wouldn't do it any longer because I value my sanity, but you could. And Mr Claude would probably do it quite happily, too.

    • DaiPlusPlus 11 hours ago

      > Why is GC needed? We always used to have to manage our own memory per app. Track what you use and release it when you're done. I used to write Windows apps using Win32 calls all day long with no GC.

      The short answer, especially for the 1990s-2000s, was developer-productivity. No-one wants to write destructors and reason about all the unpredictable ways a deallocation might fail, and more besides, for a LoB system that needs to be deployed on Monday and will only be in-use for a few weeks.

      Today, that reason still applies, but another (oft-underconsidered) reason is the ability to safely (and correctly) move objects around in-memory, which permits heap defragmentation or even moving individual objects, or larger object-graphs, to different physical RAM locations to best benefit its current CPU workers in a NUMA system, for example; this could even be generalized out to non-volatile memory storage, if that ever goes mainstream. In an existing portable C program you simply can’t do that and will have to recycle your entire process if malloc fails due to fragmentation.

      ——-

      Separately, I find that GCs are all tightly-coupled to their corresponding compiler and runtime env; fundamental design decisions of its standard library will be based on how its GC works (and rarely vice-versa), and that extends to programming language-design itself (e.g. ARC needs the compiler to add ref-counting logic; languages with GC/ARC will then intentionally eschew language-features and keywords only needed in manual-nemory-mgmt-only languages (e.g. C# and Java lack a `delete` keyword or built-in reinterpret-cast operator). Having a non-ARC GC means a std library can have a user-friendly API where functions can return entire object-graphs and then forget about it; in a C-style env you instead need to make endless design-decisions 1) expose object-graphs as C structs using raw pointers - or use opaque types that use handles instead of pointers and forcing the calling application to perform everything through some object traversal API; 2) who is responsible for allocating memory for the returned graph? The caller - or callee? If the caller, how do you supply size information first before you supply the actual data? …and without having to do the same operation twice? If it’s a callee-allocated arena or pool then how can the consumer safely/correctly pick a subset of all allocated objects they want to keep around longer than the initial pool? 3) if you anticipate C++ consumers of your C-style API is it worth supporting smart-pointers and/or platform-managed memory? Etc etc. 4) will it work if your API .so is statically-linked in a program using a shared cstdlib?

      I’m mot dunking on C specifically, but most manual-memory-management only works well when the lifetime of allocated memory exactly matches program scope lifetime (not just lexical-scope, and not just “autos”/stack-allocation either), which means each separate unit-of-work in your program needs to have a bound and deterministic lifetime of its own (e.g. a HTTP request/response). Whereas this falls apart when your program needs to gracefully handle unbound and/or non deterministic memory usage (e.g. an RTS game using a malloc’d struct for each in-game unit… and the player is amassing a Zerg rush); or just any kind of user-interactive desktop application - I know you said you were happy with Win32’s memory API (with-or-without ATL), but compare a 2000s-era Win32 program like AIM or Winamp with a 2026 desktop abomination like Discord.exe or even MS Office today: there are so many concurrently-running operations, all with criss-crossing concerns with their own shared-state - if I were a dev manager on those products I’d only permit manual-memory management if the pull-request included a Z3 proof of correctness.

StilesCrisis 1 day ago

Why did they eliminate reflection? That doesn't need huge runtime support or garbage collection.

  • to11mtm 1 day ago

    Ehh, it kinda does, at least from a binary size standpoint. Both for how reflection is handled and the compile metadata that needs to be included in the runtime (may be wrong on the second part but I'm 70% sure that's a cost)

  • Rohansi 19 hours ago

    Reflection to do what? Getting/setting fields, calling methods, etc. uses `object` which means boxing, which means allocating. Going AOT also means there is no JIT to compile methods (including generic instances) that were not statically referenced.

    • wallstop 18 hours ago

      I mean, yes, but also, no - you can generate and cache (or return manual ownership to the caller) IL/whatever runtime code that doesn't box for any reflection thing that you need on the fly, assuming the type information is available. Like you make it an explicit API to do the code gen, no JIT required.

      Just because the code isn't baked into the binary doesn't mean that it theoretically can't be done at runtime. At least, AFAICT.

      • Rohansi 6 hours ago

        It seems like you are contradicting yourself here. Just generate code that doesn't box on the fly, but without a JIT compiler? Boxing isn't even the biggest issue here - you could probably avoid that with a strongly typed reflection API, but I don't know if that makes it less useful.

        IMO the big issue is AOT compilers only compile code that is referenced statically. Without a JIT you would have no choice but to error if you try to call something that wasn't compiled in. Compiling everything is not an option because generics.

farhan291 5 hours ago

i really don't understand why there is need of no gc in c#? it already provides so many tools to make optimized binary even have aot compiler support.

SuperV1234 1 day ago

Cool project, I don't understand all the hate. This is great for gamedev and similar domains where latency matters

  • ivanjermakov 22 hours ago

    How is this great for gamedev if all C# ecosystem is not supported because of no-GC requirement?

Pannoniae 1 day ago

This thread feels like a bit of the old Dropbox thread ;)

"what is this useful for" - You want to write native code without a runtime or GC but you also don't want to deal with C++ with its arcane rules, edge cases, an awful dependency management story and complexity in general.

Rust is a good candidate for this as well, although it has quite a learning curve.

"you can already do this in standard C#" - Yes but the ecosystem assumes GC so you need to write everything yourself. There are some low allocation APIs but definitely not for everything. The concept of "C# but even lower level" is something which has a place, IMO. Just like how you can technically add assembly to C#, either by linking it with nativeAOT or emitting at runtime but it's not built-in support for inline assembly, you know.

amelius 1 day ago

The "without any GC" part has me worrying. Is this advocating to just accumulate your garbage and throw it out only once every blue moon?

Also, does it ship with GUI libraries?

  • DougN7 1 day ago

    “Memory comes from arenas you free all at once”

    • amelius 1 day ago

      Yes, but this means you can only do it at very specific points in your program. E.g. after serving a request. This doesn't work for every type of program.

      • yodon 1 day ago

        You can do this today in vanilla C#. Pause garbage collection, then resume it. Done. Even Unity's ancient Mono variants could do this almost a decade ago.

        • amelius 1 day ago

          I don't see how that solves the problem. The GC in the article is substantially simpler than the GC in "vanilla C#" ...

OnceMoreUntoThe 1 day ago

Yeah, this is just a bunch of AI slop, but, ehhm... I really don't get all the CLR GC hate? Sure, if you're running a 24-months-ago Mono build, and your game performs like crap, I can sort-of sympathize, but otherwise?

Look, I'm all-in on CLR/C#, and one of my 'apps' is a 24/7 industrial camera monitoring system, and it has been running for the past, like, 3 months, on .NET 10 with "GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency" and "stackalloc" where needed, and...

Its performance, handling 8x ~800Mb/s streams has been... absolutely okay: 0 bytes over-allocated in the past 90 days (which is the last time my CoreOS-deployment auto-rebooted: all nodes are behind a VPN and outbound-only, so the latest OMG-CRITICAL-CVE doesn't really apply), so...

"If it works, it works"

  • hirvi74 1 day ago

    > * if you're running a 24-months-ago Mono build, and your game performs like crap*

    It's always the fault of the arrow and never the archer.

    • OnceMoreUntoThe 1 day ago

      I've no idea what that's supposed to mean.

      • Dwedit 1 day ago

        That's just another way to say "A bad workman blames his tools"

  • to11mtm 23 hours ago

    I have seen a lot of GC unfriendly code.

    Hell, I actually wrote one once; it was an Elixir app port to Akka.NET, but for performance and business requirements, due to various large broadcast messages of updates (as well as a policy/setup of killing an IIS worker if it hit over a certain limit,) I actually had to manually set GCHeapHardLimit via runtimeconfig; We would produce a lot of LOH stuff and somehow the way the allocator behaved as far as lack of compaction by default and the way server GC segments work on multicore, well it caused the process to frequently go over the IIS limit and kick the process.

    Once we set GCHeapHardLimit (cause that magically enables LOH compaction,) all of those problems went away. Thing was smooth as silk after that (Well, at least until they added Dynatrace APM to the servers which caused a problem on every failover update of the SQL Backend...)

exceptione 1 day ago

It builds on top of bflat, so there is a real non-vibed base there. Nice to see people take those type of bare metal efforts even further.

kvuj 1 day ago

Doesn't C# already support AOT compilation?

  • andix 23 hours ago

    Yes, but those binaries are still quite heavy, compared to C.

    Native AOT is the exact opposite, it tries to preserve as much compatibility as possible to "normal" CLR dotnet and the BCL (it's the dotnet equivalent to JVM and JCL in Java world).

    Bflat and this project take away everything from dotnet and only leaves C# behind, mostly incompatible to existing libraries and frameworks, no GC and very basic memory management.

dosshell 1 day ago

I like arena allocators, but some how i fel like reference counting would have been a better match for C# philosophy, like swift.

jayd16 1 day ago

Does this need a fork? Just pause the GC and use these patterns?

bilekas 1 day ago

I'm not seeing why exactly..

DeathArrow 1 day ago

If you take GC out of C# and add arenas, why not use C or Zig already? If it's about the syntax, C's syntax is already similar.

  • tester756 1 day ago

    > If it's about the syntax, C's syntax is already similar.

    lol

    what about all the sane language features and stdlib?

  • andix 23 hours ago

    If you want to build real applications, don't use this. This is more like an esoteric programming language. It exists, because it can exist.

pipeline_peak 1 day ago

I’ve always wondered what C# would be like without GC. Yet without Reflection, there really isn’t anything meaningful here. It’s just nice syntax leftover.

luxuryballs 1 day ago

vote for calling it C# Zero or hmm Z#?

CAP_NET_ADMIN 1 day ago

In the age of LLMs and agentic coding - does the syntax even matter? Do you even look at the code anymore?

Just use Rust.

  • bigstrat2003 23 hours ago

    If you don't look at the code, you are committing professional malpractice. Read the damn code, don't be so lazy you can't even bother to do your job correctly.

    • CAP_NET_ADMIN 9 hours ago

      Do you read the compiler output as well?