Remix.run Logo
drnick1 7 hours ago

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

toast0 6 hours ago | parent | next [-]

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)

kunley 3 hours ago | parent | prev | next [-]

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

flohofwoe 3 hours ago | parent | prev | next [-]

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

jandrewrogers 5 hours ago | parent | prev | next [-]

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.

mitchellh 7 hours ago | parent | prev | next [-]

Fun?

pmarreck 5 hours ago | parent | prev | next [-]

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

bjourne 2 hours ago | parent [-]

Zig is not faster than C.

flohofwoe 2 minutes ago | parent | next [-]

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).

lionkor 6 minutes ago | parent | prev [-]

Would you say its always slower, or always faster?

6 hours ago | parent | prev | next [-]
[deleted]
6r17 6 hours ago | parent | prev | next [-]

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

moonlion_eth 4 hours ago | parent | prev [-]

because zig is lower level than c