Then I decided to try Nim, I found it very ergonomic and lets you write compact code that expresses the main logic without too much syntax noise. But I got blocked by some issues making it work for a UEFI target.
Then I tried Zig and got as far as parsing ACPI tables and writing an AML bytecode parser. Zig is nice and I like its optionals support and error handling approach. But I was put off by its noisy syntax (e.g. !?*[*]u8 to represent an error union of an optional pointer to a many-pointer of uint8). Also having to prepare and weave allocoators throughout most of the code that needs to dynamically allocate (which is most of the code) gets in the way of the main logic. Even little things like string concatenation or formatting becomes a chore. In the end I realized that Zig is not for me.
So I got back to Nim and resolved the issues that were blocking me. I'm now on my journey to write a complete kernel in Nim (so far I have access to UEFI services and ACPI table parsing and on my way to get interrups working). The code is pleasant to write and read. Also the language and the stdlib documentation is great (Zig's stdlib documentation is almost non-existent.)
Overall, I found that systems programming is very satisfying, and you can depend on specs that rarely change (some are over 20 and 30 years old and still work the same way today) and is quite a welcome change from web dev where it depends on tech de jour.
Edit: Here are the github repo links:
- C kernel: https://github.com/khaledh/bitflow
- Zig "kernel": https://github.com/khaledh/axiom-zig
- Nim "kernel": https://github.com/khaledh/axiom