24 comments

  • raincole3 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.<p>You can also distribute apps without .NET runtime with NativeAOT.<p>I&#x27;m sure there are people who want a C# without GC, but for me it&#x27;s just... sufficient enough.
    • randomNumber72 hours ago
      &gt; I&#x27;m sure there are people who want a C# without GC<p>There&#x27;s also C++ and although it is a monstrosity the practical thing would be to use that.<p>If you want a serious alternative to C++ I don&#x27;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.
    • jeremyjh1 hour 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?
      • dragonwriter23 minutes 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.
      • DANmode1 hour ago
        Such as?
    • lowbloodsugar1 hour 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.<p>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#.<p>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.<p>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.
    • Waraqa3 hours ago
      NativeAOT can&#x27;t compile for DOS.
      • dragonwriter21 minutes 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.
      • raincole3 hours 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.
    • samuelknight3 hours ago
      NativeAOT gets rid of JIT not GC. The language is rich enough that you can avoid making garbage though.
  • bob10294 hours ago
    The GC is a feature. Not a bug to be eliminated.<p>GC is not surrendering control. That seems to be HN&#x27;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&#x27;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.<p>If your clever scheme wouldn&#x27;t work with a GC-managed heap, it probably won&#x27;t work with one managed by hand either.
    • wk_end3 hours ago
      Garbage collection is a feature but it&#x27;s also a <i>trade-off</i>, like most things in engineering. IMO it&#x27;s a worthwhile trade-off more often than a lot of people think (though a lot of people don&#x27;t think enough about it). But there&#x27;s also times that it&#x27;s not worthwhile, and we shouldn&#x27;t pretend otherwise.
    • andai3 hours ago
      GC is literally surrendering control.<p>But it really depends on what you&#x27;re doing. You can use the wrong tool for a job, but you can also use the right tool. It depends on the job.
      • jayd163 hours ago
        It&#x27;s only surrendered control if you refuse to understand it and how to control it.
        • generichuman43 minutes ago
          The (Tracing) Garbage Collector abstraction isn&#x27;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?<p>I&#x27;m not saying manage memory manually. You can switch to a language that is reference counted. Then at least that abstraction guarantees deterministic deallocation.<p>That comes with another set of trade-offs such as having to pay attention to atomic reference counts, making sure there&#x27;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.
        • unrented79773 hours 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.
        • lilbigdoot1 hour ago
          There&#x27;s still limits on that control.
          • unrented797736 minutes ago
            You&#x27;ll need to be a lot more specific, because C# offers you a <i>lot</i> 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 <i>relocation</i>. You have pointers and unsafe contexts. Frankly I can&#x27;t think of anything you&#x27;d want to do with GC that isn&#x27;t offered already.<p>One does not <i>have</i> to live with the tradeoffs that C#&#x27;s default GC makes. One just needs to understand how the GC works and how it is controlled.
    • dafelst3 hours ago
      Indeed - even Unreal Engine uses GC for all its internal object management. It&#x27;s not a language level thing, more a runtime entity thing, but it is there. It simplifies object lifetime management quite a bit.<p>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&#x27;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.
    • Jooror3 hours 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.<p>Agreed that it’s no longer a bottleneck for games; profile—and-optimize approaches are very effective and the tooling has never been better.
    • jameshart3 hours ago
      Exactly. The problem People have with GC is not garbage collection per se, it is garbage collection <i>pressure</i>. The solution to which isn’t doing away with the GC, it is managing and controlling allocation.
    • 9999000009993 hours 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.
    • Johanx641 hour ago
      Arenas, etc is GC done right.<p>Or rather GC done explicit.<p>You control when and where and how garbage gets collected in various buckets and disposed off.<p>Without the performance hit of fully automatic GC.<p>&gt; Risking memory leaks is crazy when it&#x27;s not something the customer is demanding.<p>Memory leaks have NEVER been a significant source of bugs.<p>Memory corruption has always been the problem (lack of memory safety, ie. operating in perpetual unsafe block), not the memory leaks.<p>Memory leaks are relatively trivial to track and account for in comparison.
      • pron10 minutes ago
        Generational moving GCs work much like arenas, and they work without the limitations of arenas and without the performance hit of malloc&#x2F;free. That&#x27;s not to say arenas aren&#x27;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.
      • jeremyjh1 hour ago
        [dead]
  • buybackoff14 minutes 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&#x27;s OK to allocate many GBs and then pause explicitly.<p>Random forced pauses are the only problem that comes from GC, otherwise it&#x27;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&#x2F;free. However, GC is surrendering control over when a program may be paused.
    • ablob10 minutes ago
      Can&#x27;t you just initialize and then do a NoGCRegion? It would give you everything except the monitoring I think.
  • bilekas4 minutes ago
    I&#x27;m not seeing why exactly..
  • YuechenLi3 hours ago
    So... What does this have over using NativeAOT which already exists?<p>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&#x27;s not like you can&#x27;t do Span&lt;T&gt; and ref structs in modern C# for manual low level memory control already.<p>So my question is just... why?
    • MarkSweep4 minutes 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 &quot;2kb game for windows&quot; or &quot;4kb game targeting UEFI&quot; (i.e. no operating system).<p><a href="https:&#x2F;&#x2F;migeel.sk&#x2F;blog&#x2F;2023&#x2F;12&#x2F;08&#x2F;building-bare-metal-bootable-game-for-raspberry-pi-in-csharp&#x2F;" rel="nofollow">https:&#x2F;&#x2F;migeel.sk&#x2F;blog&#x2F;2023&#x2F;12&#x2F;08&#x2F;building-bare-metal-bootab...</a><p>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.
  • hollowonepl4 hours 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&#x2F;cleaner syntax that does not inherit so much from C and POSIX archeology.<p>Nice POC, especially on MS-DOS but nothing truly relevant in the long run, I’m afraid
    • andai4 hours ago
      I was already sold, you didn&#x27;t need to sell me harder!
    • lowbloodsugar59 minutes 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.
      • hollowonepl55 minutes ago
        point is this zero c# doesn&#x27;t have GC and won&#x27;t release your blocks automatically. that&#x27;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.<p>I commented this one explicitly because that zero c# platform pitched here is just the language syntax you know and then manual new&#x2F;delete just like in c++
        • lowbloodsugar40 minutes ago
          &gt; standard C# developer like you guys<p>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).
    • jayd162 hours ago
      What if I told you both Unity and Unreal use C# extensively? Plenty of game devs are familiar with memory management and C#.<p>That said, I don&#x27;t see how this project fits in all that nicely.
      • hollowonepl58 minutes 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&#x27;t need to even think about mutations.
  • Dwedit2 hours ago
    You really don&#x27;t want to use C# with the &quot;Bflat&#x2F;Zero&quot; runtime library. Even something very basic like strings is unsupported. It becomes C code with funny syntax that doesn&#x27;t align well with the language.<p>I have not yet tested out Beef, but it seems to be more in line with what you&#x27;d want from a native C#-like language.
  • SuperV123425 minutes ago
    Cool project, I don&#x27;t understand all the hate. This is great for gamedev and similar domains where latency matters
  • StilesCrisis4 hours ago
    Why did they eliminate reflection? That doesn&#x27;t need huge runtime support or garbage collection.
  • exceptione2 hours 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.
  • Pannoniae3 hours ago
    This thread feels like a bit of the old Dropbox thread ;)<p>&quot;what is this useful for&quot; - You want to write native code without a runtime or GC but you also don&#x27;t want to deal with C++ with its arcane rules, edge cases, an awful dependency management story and complexity in general.<p>Rust is a good candidate for this as well, although it has quite a learning curve.<p>&quot;you can already do this in standard C#&quot; - Yes but the ecosystem assumes GC so you need to write <i>everything</i> yourself. There are some low allocation APIs but definitely not for everything. The concept of &quot;C# but even lower level&quot; is something which has a place, IMO. Just like how you can <i>technically</i> add assembly to C#, either by linking it with nativeAOT or emitting at runtime but it&#x27;s not built-in <i>support</i> for inline assembly, you know.
  • vips7L4 hours ago
    Reminds me of Beef: <a href="http:&#x2F;&#x2F;www.beeflang.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.beeflang.org&#x2F;</a>
  • OnceMoreUntoThe3 hours ago
    Yeah, this is just a bunch of AI slop, but, ehhm... I <i>really</i> don&#x27;t get all the CLR GC hate? Sure, if you&#x27;re running a 24-months-ago Mono build, and your game performs like crap, I can sort-of sympathize, but otherwise?<p>Look, I&#x27;m all-in on CLR&#x2F;C#, and one of my &#x27;apps&#x27; is a 24&#x2F;7 industrial camera monitoring system, and it has been running for the past, like, 3 months, on .NET 10 with &quot;GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency&quot; and &quot;stackalloc&quot; where needed, and...<p>Its performance, handling 8x ~800Mb&#x2F;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&#x27;t really apply), so...<p>&quot;If it works, it works&quot;
    • hirvi743 hours ago
      &gt; * if you&#x27;re running a 24-months-ago Mono build, and your game performs like crap*<p>It&#x27;s always the fault of the arrow and never the archer.
      • OnceMoreUntoThe2 hours ago
        I&#x27;ve no idea what that&#x27;s supposed to mean.
        • Dwedit2 hours ago
          That&#x27;s just another way to say &quot;A bad workman blames his tools&quot;
  • amelius4 hours ago
    The &quot;without any GC&quot; part has me worrying. Is this advocating to just accumulate your garbage and throw it out only once every blue moon?<p>Also, does it ship with GUI libraries?
    • DougN74 hours ago
      “Memory comes from arenas you free all at once”
      • amelius3 hours 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&#x27;t work for every type of program.
        • yodon2 hours ago
          You can do this today in vanilla C#. Pause garbage collection, then resume it. Done. Even Unity&#x27;s ancient Mono variants could do this almost a decade ago.
          • amelius1 hour ago
            I don&#x27;t see how that solves the problem. The GC in the article is substantially simpler than the GC in &quot;vanilla C#&quot; ...
  • kvuj3 hours ago
    Doesn&#x27;t C# already support AOT compilation?
  • dosshell4 hours ago
    I like arena allocators, but some how i fel like reference counting would have been a better match for C# philosophy, like swift.
  • andyfilms14 hours ago
    Finally, C--
    • lpedrosa4 hours ago
      Don&#x27;t you mean C♭?
  • jayd163 hours ago
    Does this need a fork? Just pause the GC and use these patterns?
  • DeathArrow3 hours ago
    If you take GC out of C# and add arenas, why not use C or Zig already? If it&#x27;s about the syntax, C&#x27;s syntax is already similar.
    • tester7561 hour ago
      &gt; If it&#x27;s about the syntax, C&#x27;s syntax is already similar.<p>lol<p>what about all the sane language features and stdlib?
  • pipeline_peak3 hours 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.
  • luxuryballs3 hours ago
    vote for calling it C# Zero or hmm Z#?
  • CAP_NET_ADMIN3 hours ago
    In the age of LLMs and agentic coding - does the syntax even matter? Do you even look at the code anymore?<p>Just use Rust.
  • reverseblade228 minutes ago
    [dead]