Building a self-contained game in C# under 2 kilobytes

by shanselmanon 1/2/2024, 6:30 PMwith 40 comments

by Genboxon 1/2/2024, 10:45 PM

I love the low level .NET stuff Michael Strehovsky makes. Microsoft has built a feature-rich and easy-to-use environment, but it makes .NET developers think there is only one way to use it: create csproj and call dotnet build.

But underneath the covers, there is an extremely powerful compiler (Roslyn) and build-system (msbuild). Combine that with the flexibility of C# and you can develop pretty much anything.

by delta_p_delta_xon 1/3/2024, 12:02 AM

It is pretty impressive that even without third-party tools, the binary went from 64 MB to ~1 MB. IMO future versions of .NET should add more of such optimisation flags as default in a Release build.

by askiiarton 1/3/2024, 10:10 AM

In a similar vein, there's Can you fit a whole game into a QR code? by MattKC, which is limited to about 3 kilobytes (2,953 bytes)

https://youtu.be/ExwqNreocpg

by TillEon 1/2/2024, 9:21 PM

This is really cool, but it's funny to use C# primarily as an awkward substitute for C as you call Win32.

For most practical purposes, the default .NET 8 AOT is great if you really need native code.

by MStrehovskyon 1/2/2024, 10:55 PM

Someone with an iPhone told me the webm video embedded in the article still doesn't work on iPhones in 2024 so here's another link to the video: https://twitter.com/MStrehovsky/status/1742101904250060842

by deafpolygonon 1/2/2024, 9:15 PM

"Win32 is the only stable ABI on Linux" ;)

by tiberriver256on 1/3/2024, 1:21 AM

He makes this look easy! Surprising how far you can take things with OOTB .NET.

by nwellinghoffon 1/3/2024, 7:17 AM

Very cool. What are the practical implications for this? Would it ever be wise to deploy these techniques for a commercial program? Is the end result more memory efficient during execution?

by WhereIsTheTruthon 1/3/2024, 5:20 PM

Michal and the whole CoreRT team saved C# for me, one of the very few people i respect from Microsoft

by mgerullison 1/2/2024, 8:49 AM

Sadly the video won’t play on my iPhone

by TheRealPomaxon 1/3/2024, 5:34 PM

Pretty sure you just joined the demo scene.