News for hackers. Stuff that matters.
Re:SnakeOS: Bootable x86 snake game in Rust by MStrehovsky on Thursday August 26, 2021 @11:04PM (#28323872)
> 212kB

Here's a 11 kB bootable x86-64 version of the game written in C# https://github.com/kant2002/SeeSharpSnake/tree/kant/uefi#run....

There's an accompanying article with a video at the bottom https://codevision.medium.com/running-c-snake-inside-uefi-df....

Re:SnakeOS: Bootable x86 snake game in Rust by jaclaz on Friday August 27, 2021 @05:24AM (#28325776)
Re:SnakeOS: Bootable x86 snake game in Rust by pornel on Friday August 27, 2021 @10:10AM (#28328014)
This implementation uses async/await, data structures from Rust's standard library (alloc crate), plus streams and channels (30 dependencies in total), so it's pretty fancy for a "no_std" project.

Bare-bones Rust executables can start at about 3.5KB, and code size increase on top of that is comparable to C or C++. Rust can be a "portable assembler" if you write code in such style. It can also generate lots of code if you lean into generics (same issue as with C++ templates).

Re:SnakeOS: Bootable x86 snake game in Rust by elromulous on Friday August 27, 2021 @12:42AM (#28324381)
So I admittedly only skimmed that link very briefly. But... how? I would think the c# runtime alone would balloon this to some astronomical size.

Edit: Got my answer. /p:Mode=CoreRT-NoRuntime, /nostdlib, and a bunch of others.

Re:SnakeOS: Bootable x86 snake game in Rust by option_greek on Friday August 27, 2021 @04:15AM (#28325453)
So how does it work. Where do the standard library functions come from? Where do all the garbage collecting functionality gets loaded from?. Or is it more like pinvoking a reduced external library in C for all needed functionality.
Re:SnakeOS: Bootable x86 snake game in Rust by hahamrfunnyguy on Friday August 27, 2021 @05:42AM (#28325869)
He used a few different techniques.

1. Used CoreRT instead of the standard .NET libraries 2. He avoided using functionality that would use GC in the first place 3. Created his own alternative runtime library w/out GC and exception handling 4. Created a base type library for some of the System functions 5. Re-directed certain functions like Thread.Sleep to smaller implementations in specific libraries.

The blog posting is well worth reading:

https://medium.com/@MStrehovsky/building-a-self-contained-ga...

Re:SnakeOS: Bootable x86 snake game in Rust by pjmlp on Friday August 27, 2021 @11:37AM (#28329189)
This is also a very good example that not all languages with GC are created equal, some do provide the mechanisms to do alternative ways of managing resources.