Tiny Binaries (2021)
pablotron.org
pablotron.org
const std = @import("std");
pub fn main() !u8 {
const stdout = std.io.getStdOut().writer();
try stdout.print("hi!\n", .{});
return 0;
}
...using the following compiler flags: zig build-exe main.zig -target x86_64-linux -O Debug
#=> 965k
zig build-exe main.zig -target x86_64-linux -O ReleaseSafe
#=> 788k
zig build-exe main.zig -target x86_64-linux -O ReleaseFast
#=> 695k
zig build-exe main.zig -target x86_64-linux -O ReleaseSmall
#=> 9k
Zig with "-O ReleaseSmall" optimizations creates a 9k binary, putting it at 5th place on OP's chart.That's smaller than all but five of these "hi!" executables.
With C++ and FLTK you can draw a GUI window that says hello world with your static binaries starting at 100KB
upx being acceptable or not is no different than how none of the best performing examples here would be acceotable in most situations either, not just the upx ones, just for other reasins. No company making a random app that didn't have a critical need for this metric would tolerate you writing it in assembly or even c with muscl etc instead of something everyone else can maintain.
This is just a reminder of how much nonsense languages like rust are packing into their binaries without regard for the people using them.
If I wrote most things in this way, everyone else would think I was just trying to create artificial job security. Probably the very first reviewer would just reject it instantly and it would never even get started down that path. (unless a compelling justification could be demonstrated, and for most things there is no such justification)
I'm not denying this is cool. I like it too. I'm only saying that the upx consideration doesn't matter, because that's an application concern while this is more like theoretical research, and because it's not even the only problem with using code like this in your average real project.
No one is thinking that is anything other than a demonstration that it can be done in a few hundred bytes.
But it is possible to make software with C++ and other languages and actually start at 100KB or less.