Show HN: I wrote an OS in 1000 lines of Zig
7 comments
·September 18, 2025botirk
hdjxjdjdkshsb
Curious: is it 1k lines of zig total with no libraries or 1k lines of zig with libraries?
noone_youknow
Nice work! Looks like most of the basics are covered, and meanwhile in my current kernel the RISC-V entrypoint is >700 lines (of C) just to get to the arch-independent entrypoint!
I was just looking around for your input/output code, I don’t know zig but I expected to find putChar in kernel.zig based on the import in common.zig, but I don’t see it, should I be looking somewhere else? I didn’t see any simple command line processing either as mentioned in the README?
Mostly just looking around since your README mentioned VGA (and you seem to have a BIOS boot) which struck me as interesting on a RISC-V project, I was curious if you were actually using the SBI routines or had actually mapped in a VGA text mode buffer?
cyberclimb
Hi botirk, really interesting project!
If I build the project what is the output format and how could configure things to boot it?
I know how to this with IMG and ISO files of course but not sure what to do with the build output if it's an executable?
Also any insights into whether this would also boot on an ARM machine? Thanks!
coffeeri
Check the build.zig file. It defines the arguments for QEMU to run the OS.
You should be able to run zig build run.
null
null
I wanted to understand what the bare minimum of an operating system looks like.
So I built one in Zig, keeping the whole thing under 1000 lines of code.
It can: → Boot from GRUB → Manage memory → Schedule simple tasks → Output text to VGA
The point was not to make it feature-rich, but to show how much is possible with just a few hundred lines if you strip everything down to the essentials.