Show HN: Zero C# – C# without a runtime or GC onurgumus.github.io · 172 points ·...
HN Best 30 @best30
Show HN: Zero C# – C# without a runtime or GC onurgumus.github.io · 172 points · 120 comments · HN thread
TL;DR Zero C# is a Show HN fork of the bflat AOT compiler that compiles C# to small native programs with no .NET runtime and no garbage collector. Memory is managed with arenas freed all at once, and a small custom library replaces the BCL; the same hello-world builds for Linux, macOS, Windows, WebAssembly and DOS on a 386. The thread (120 comments) is mostly skeptical about who would use it, with the GC debate taking up much of the discussion.
- Compiles C# (keeping syntax, type checking, generics, unions) straight to native code with no .NET runtime and no garbage collector.
- Memory comes from arenas that are freed all at once; a small library provides strings, collections, input and output on those terms.
- Hello world is about 11 KB on Windows, 40 KB on Linux and 64 KB on macOS per the page; the same source is tested for identical output across targets.
- Targets include Linux x64/arm64, macOS on Apple Silicon, Windows x64, WebAssembly (WASI) and DOS on a 386 via the HX extender.
- Removed features include the garbage collector, the .NET runtime, catching exceptions (errors are returned as unions), reflection and async.
- The project is a fork of bflat, and the library replaces the standard BCL, so existing C# code and libraries generally will not compile.
Discussion The thread is largely skeptical and argumentative. Many commenters question the purpose of a GC-free C# when NativeAOT, Span, unsafe code and Marshal already exist, and point out that without the standard library and ecosystem, most existing code cannot be ported. A long sub-thread debates whether garbage collection is a feature or a control trade-off, with arguments about pauses, arenas versus tracing GCs, and temporal memory safety. Some commenters defend the project as a valid niche for demoscene, bare-metal or latency-sensitive work, and a few make jokes about the name. The mood is mixed: curious and technically engaged, but mostly unconvinced about practical use.
- Little practical use; existing C#, NativeAOT or other languages already cover it (many): Commenters argue NativeAOT, Span and unsafe code already give low-level control, and that without the BCL and ecosystem the project is hard to justify. Several suggest Rust, Zig or C instead.
- GC is a feature and a worthwhile trade-off (many): Many argue garbage collection boosts productivity and memory safety, and that pauses are manageable with profiling, pooling and GC tuning. They see manual or arena memory as error-prone for most programs.
- GC control is limited and some workloads need it removed (some): Some commenters, including those with latency-sensitive or real-time needs, want a no-GC or time-bounded collection mode. They say GC pauses and unpredictable allocation are real problems that tuning cannot fully fix.
- Useful for demoscene, bare-metal and tiny binaries (some): Several see the project as a fun or educational showcase for very small executables and bare-metal programs, not a production tool. A fork of the .NET runtime is seen as hard to maintain long term.
- Arenas are a form of GC or a memory-lifetime problem (a few): A minority notes arenas and tracing GCs solve similar problems, and that arenas do not fix leaks or temporal safety. Reference counting is suggested as a closer fit to C# than arenas.
- Reflection removal and missing ecosystem limit usefulness (a few): Commenters note that without reflection, async and the standard library, the result is closer to C with C# syntax. Some ask why reflection was dropped, and answers mention boxing and AOT limits.
Links from the comments
- SeeSharpSnake, a C# snake game that a commenter says has a DOS compile option under NativeAOT.
- Blog post on building a bare-metal bootable game for Raspberry Pi in C#, cited as an example of bflat-style demo work.
- Example from the Goose language showing malloc/free-style management built on top of arenas.
- Beef language site, mentioned as a native C#-like language alternative.
#csharp #garbageCollection #nativeAot #bflat #memoryManagement #embedded