logoalt Hacker News

drnick1today at 4:31 AM9 repliesview on HN

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


Replies

toast0today at 4:59 AM

Because you can is a pretty traditional reason.

Zig is supposed to be an improvement upon C, so doing C things with it seems reasonable.

Kind of neat that there's no need for a separate assembly file although there is inline assembly. Might get better (or worse) syntax support for separate assembly files? But it doesn't make a big difference until there's more features that need it (interrupts, threads/processes and maintaining their stacks, syscalls, starting other processors, etc)

kunleytoday at 7:53 AM

I guess one of good reasons is easy cross-compilation.

But also, I can see some amount of weird hooray optimism in this project, like: totally confusing claim that the thing is bare metal when it's still being run under an emulator; also, calling it a kernel is a huge overstatement

flohofwoetoday at 7:57 AM

In this case, better tooling and consistency. E.g. the small block of inline assembly would already be trouble for some C compilers.

jandrewrogerstoday at 6:20 AM

Zig is essentially a substantially improved and enhanced C, both in character and intent. There is a lot to recommend it for applications where you might otherwise use C.

mitchellhtoday at 4:39 AM

Fun?

6r17today at 4:59 AM

What's the point writing another kernel in C ???

show 1 reply
moonlion_ethtoday at 7:13 AM

because zig is lower level than c

pmarrecktoday at 6:12 AM

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

show 1 reply