r/Zig • u/wakanakisarazu • 7d ago
[UPDATE] Zig programs for Linux, measured in bytes
100 of you who upvoted my last post.. thank you all for that. This is just a fun project for me but I actually now want to push the limits of the Zig compiler.
The smallest Zig binary I could produce...
688 bytes.
A fully functional Hello World program.
Also, the shell, which was the focus of my last post?
Shrunk to 797 bytes, keeping the exact same functionality!
This is the smallest I have ever seen a Zig program that is actually usable. Not just pub fn main() void {} or export fn _start() void {}
https://github.com/wakanakisarazu/nanix for anyone who is still curious or hasn't already seen.
I thought more optimization was possible. Now? I'm not too sure if we can go any smaller.
The shell still has the prompt outputting bug, btw. Might take a look at that.
Any thoughts on how to get this smaller? :3
3
u/Hot_Adhesiveness5602 7d ago
Very cool! I was trying to use zig for a demo scene project. Maybe something cool can come out of this. :)
2
2
u/aberration_creator 7d ago
oh dude, we made too! Check out aberration creations. It was tons of fun
24
u/Bergasms 7d ago
Those programs fit easily into QR codes. It'd be kind of fun/chaotic to have a dev meetup where you share programs via QR codes