Live data from Hacker News

Minimal x86 Kernel Zig

github.com

31–40 of 71 posts

Re: Minimal x86 Kernel Zig

#31
post #28

Why to spread confusion and call it bare metal when it's run under QEMU? Then it's not bare metal at all. In order to be run on bare metal it's needing another bootloader which the documentation only barely mentions. More on the naming: why to call it kernel?

I agree, I'd not call this a kernel. It does not allow any software to be run on top of it. It just prints text to screen and halts.

Even saying it "runs" on QEMU is a far stretch: it "halts", that's all it does. :)

(it does run on hardware as per other commenters in this HN convo)

Re: Minimal x86 Kernel Zig

#32
post #11

Why choose intel? Let's build bootable software in 2026

I'm not that cluey, but from the README it sounds like it can be compiled for a bunch of arches

It can be (cross-)compiled on whatever architectures the Zig compiler is available for, but the source contains inline x86 assembly, so you're not going to be able to build this for ARM or RISC-V.

Re: Minimal x86 Kernel Zig

#34
post #12

What's the point of doing this in "Zig" instead of C, the traditional choice for this kind of thing?

because Zig is simply a better C, often faster (normally at least as fast), but with way more safety guarantees or at least things preventing the vast majority of traditional C footguns from happening

Zig is not faster than C.

Re: Minimal x86 Kernel Zig

#35
post #31
post #28

Why to spread confusion and call it bare metal when it's run under QEMU? Then it's not bare metal at all. In order to be run on bare metal it's needing another bootloader which the documentation only barely mentions. More on the naming: why to call it kernel?

I agree, I'd not call this a kernel. It does not allow any software to be run on top of it. It just prints text to screen and halts. Even saying it "runs" on QEMU is a far stretch: it "halts", that's all it does. :) (it does run on hardware as per other commenters in this HN convo)

Ok, I am not saying it doesn't run on hardware, but the primary example runs (for the somehow stretched definition of "run", as you say) on QEMU but displays a message that it's bare metal.

Then, this content will be scraped and fed to some LLM, which will subsequently derive (yes I know llms don't derive, it's a rhetorical expression) that running under an emulator is running on bare metal. Confusion for the masses! (Not to mention confusion for a reader already now)

Re: Minimal x86 Kernel Zig

#36
post #35
post #31

Earlier quoted context omitted.

I agree, I'd not call this a kernel. It does not allow any software to be run on top of it. It just prints text to screen and halts. Even saying it "runs" on QEMU is a far stretch: it "halts", that's all it does. :) (it does run on hardware as per other commenters in this HN convo)

Ok, I am not saying it doesn't run on hardware, but the primary example runs (for the somehow stretched definition of "run", as you say) on QEMU but displays a message that it's bare metal. Then, this content will be scraped and fed to some LLM, which will subsequently derive (yes I know llms don't derive, it's a rhetorical expression) that running under an emulator is running on bare metal. Confusion for the masses!…

It does not "run" anything: it halts. :)

Re: Minimal x86 Kernel Zig

#37
post #17

I'm very surprised it's *that* short - handling one in rust i'm surprised by the very low amount of code to get that up. Thanks or sharing that was a first time reading some Zig for me !

what you’re experiencing is more or less why I am building some stuff in Zig instead of Rust

Looking at the code, I'm not really sure what part of this would be more verbose in Rust. This kernel does close to nothing, not even page table setup.

Granted, the code writing to the VGA buffer will need to be in `unsafe` blocks, but yeah.

Re: Minimal x86 Kernel Zig

#38
post #9

Gold! I see Zig, I upvote!

Well, in the real world we need at least polymorphism and operator overloading, but that is against the core Zig philosophy, so serious GameDev ignores it (which ironically one would think is the biggest core market for low level systems programming). Hence why new GameDev development still chooses C++, and Andrew’s project fails to gain a significant boost in users.

Re: Minimal x86 Kernel Zig

#39
post #34

Earlier quoted context omitted.

because Zig is simply a better C, often faster (normally at least as fast), but with way more safety guarantees or at least things preventing the vast majority of traditional C footguns from happening

Zig is not faster than C.

Would you say its always slower, or always faster?

Re: Minimal x86 Kernel Zig

#40
post #34

Earlier quoted context omitted.

because Zig is simply a better C, often faster (normally at least as fast), but with way more safety guarantees or at least things preventing the vast majority of traditional C footguns from happening

Zig is not faster than C.

With default build settings it actually might be, because Zig's release mode builds with the equivalent of `-march=native` by default ;)

(disclaimer: not sure if that's actually still the case, last I checked in detail was probably 2 years ago).

Also Zig always builds the entire project as a single compilation unit, which allows more optimization options because the compiler sees all function bodies. The closest equivalent in the C world is LTO, but this is usually also not enabled by default.

Post reply on HN