← Back to context

Comment by leeoniya

6 years ago

> This will produce a single EXE file that has whopping 65 MB. The produced EXE includes the game, the .NET Runtime, and the base class libraries that are the standard part of .NET. You might say “still better than Electron” and call it good, but let’s see if we can do better.

Perhaps a better JS baseline would be QuickJS [0].

Once 1.2MB was reached:

> Now we’ve reached the end of what’s possible with the .NET SDK and we need to get our hands dirty. What we’re going to do now is starting to be ridiculous and I wouldn’t expect anyone else to do this. We’re going to rely on the implementation details of the CoreRT compiler and runtime.

QuickJS is 620K.

I guess that doesn't include any kind of facility for rendering to the screen (besides basic barfing to stdout) or interacting with keyboard/mouse. i wonder how much code would be needed to add support for a basic canvas pixeldata api & keyboard event handling.

[0] https://bellard.org/quickjs/

Very little, actually. You'd need CreateWindow to get a surface to render onto, and from there you have access to GDI, GDI+, OpenGL, and D3D via P/Invoke

If by "basic Canvas pixelData" you mean blitting an array of pixels in a loop, that would require a grand total of 4 API calls: CreateWindow, GetDC, CreateBitmap, BitBlt. Keyboard and mouse handling would be a dozen lines of code to process the corresponding window messages in the event loop.

I bet this would all still fit in under 64Kb.