NewsCrawler.org

Zero C#: C# without a runtime or garbage collector

Zero C#, C# with nothing underneath. Kept: C# 15, real generics, interfaces, records and lambdas. Left out: the garbage collector and the .NET runtime. Runs on Linux, macOS, Windows, WebAssembly and DOS.
Image: onurgumus.github.io

A fork of bflat compiles C# straight to a small native program: no .NET runtime, no garbage collector[1], and nothing to install where it runs. The project keeps C# syntax, type checking and generics. Memory comes from arenas[2] that are freed all at once, and a small library provides strings, collections, input and output.

The same source builds for Linux, macOS, Windows, WebAssembly and DOS on a 386. The hello-world sample is 11 KB on Windows and 40 KB on Linux. Each build is checked by the same test suite, which requires the same output on every target.

Some common features are missing. Memory must be freed through arenas instead of a garbage collector. Exceptions are not caught: throw ends the program, so errors are returned as unions. Reflection and async are not included.

Read the original onurgumus.github.ioDiscussion

Discussion

Commenters are mostly skeptical. Several point out that NativeAOT already produces standalone C# binaries, and others say the ecosystem and libraries assume a garbage collector. Some defend the GC, citing a months-long industrial camera monitoring system, and Beef is named as a closer alternative.

Sources

Published: First seen: Читать по-русски

Open as a page