24 points · by peter_d_sherman · 3y ago · 13 comments
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.