Live data from Hacker News

Hobby x86 kernel written with Zig

github.com

1–10 of 229 posts

Re: Hobby x86 kernel written with Zig

#4
Hi, author here! I've just finished writing the pre-emptive multitasking [0](only round robbin though, nothing fancy).

I'm currently writing an ATA driver [1], the idea is to implement ext2.

I used to do this in Rust but I switched to zig for maintainability and readability over Rust. It seems that with `comptime` I'm able to make a lot of things optimal.

Overall I have to say kernel programming is _hard_ but very rewarding when it finally works, it's really demystifying computers for me!

[0] https://wiki.osdev.org/Brendan%27s_Multi-tasking_Tutorial

[1] https://wiki.osdev.org/IDE

Re: Hobby x86 kernel written with Zig

#5

Hi, author here! I've just finished writing the pre-emptive multitasking [0](only round robbin though, nothing fancy). I'm currently writing an ATA driver [1], the idea is to implement ext2. I used to do this in Rust but I switched to zig for maintainability and readability over Rust. It seems that with `comptime` I'm able to make a lot of things optimal. Overall I have to say kernel programming is _hard_ but very re…

Looks awesome! Planning to do a similar thing in Jai once it comes out

Re: Hobby x86 kernel written with Zig

#6

Hi, author here! I've just finished writing the pre-emptive multitasking [0](only round robbin though, nothing fancy). I'm currently writing an ATA driver [1], the idea is to implement ext2. I used to do this in Rust but I switched to zig for maintainability and readability over Rust. It seems that with `comptime` I'm able to make a lot of things optimal. Overall I have to say kernel programming is _hard_ but very re…

> I used to do this in Rust but I switched to zig for maintainability and readability over Rust.

Can you expand on this ? I'm asking out of curiosity because I want to learn a "system" programming language (for whatever definition there is to this term). So far I briefly tried Rust and Nim and found the former more difficult to read. I know nothing about Zig, how would you place it between these two ?

Re: Hobby x86 kernel written with Zig

#8

Hi, author here! I've just finished writing the pre-emptive multitasking [0](only round robbin though, nothing fancy). I'm currently writing an ATA driver [1], the idea is to implement ext2. I used to do this in Rust but I switched to zig for maintainability and readability over Rust. It seems that with `comptime` I'm able to make a lot of things optimal. Overall I have to say kernel programming is _hard_ but very re…

Great work!

Re: Hobby x86 kernel written with Zig

#9
post #6

Hi, author here! I've just finished writing the pre-emptive multitasking [0](only round robbin though, nothing fancy). I'm currently writing an ATA driver [1], the idea is to implement ext2. I used to do this in Rust but I switched to zig for maintainability and readability over Rust. It seems that with `comptime` I'm able to make a lot of things optimal. Overall I have to say kernel programming is _hard_ but very re…

> I used to do this in Rust but I switched to zig for maintainability and readability over Rust. Can you expand on this ? I'm asking out of curiosity because I want to learn a "system" programming language (for whatever definition there is to this term). So far I briefly tried Rust and Nim and found the former more difficult to read. I know nothing about Zig, how would you place it between these two ?

I'm curious too, I'm quite familiar with Rust and never written any Zig in my life so I went digging through the source and I find the syntax remarkably similar for the most part. The only thing that stood out is that apparently you can drop the braces for single-line `if` bodies like in C whereas Rust makes them always mandatory but I'm firmly on Rust's side on this one.

The part where Rust can get really messy is when you involve generic programing and traits, especially when lifetimes are involved, but I couldn't find any obviously generic code in this codebase.

EDIT: after digging a bit deeper into Zig it looks like it uses C++'s style duck typing for metaprograming instead of a trait-based approach like Rust? It definitely removes some overhead to writing generic code but I'm not sure about readability and maintainability... But I'm going to stop here because I'm about to go full fanboy for Rust.

Re: Hobby x86 kernel written with Zig

#10
post #6

Hi, author here! I've just finished writing the pre-emptive multitasking [0](only round robbin though, nothing fancy). I'm currently writing an ATA driver [1], the idea is to implement ext2. I used to do this in Rust but I switched to zig for maintainability and readability over Rust. It seems that with `comptime` I'm able to make a lot of things optimal. Overall I have to say kernel programming is _hard_ but very re…

> I used to do this in Rust but I switched to zig for maintainability and readability over Rust. Can you expand on this ? I'm asking out of curiosity because I want to learn a "system" programming language (for whatever definition there is to this term). So far I briefly tried Rust and Nim and found the former more difficult to read. I know nothing about Zig, how would you place it between these two ?

Zig is lower level than either (it's more like C than C++: expect to manually call 'free'on allocated values). It has a lot of nice improvments over C however, like proper arrays, no null, a module system, and proper compile time evaluation (no need for the hacky preprocessor).
Post reply on HN