Asahi Lina (朝日リナ) on Nostr: Almost every thread about Rust for Linux ends up with someone saying "why not Zig ...
Almost every thread about Rust for Linux ends up with someone saying "why not Zig instead"? And usually the answer is just "it's less mature" or "nobody pushed it".
I didn't know anything about Zig, so I decided to take a look today... and I'm not very impressed ^^;;
I learned that Zig does not have:
- Destructors
- Macros
- Lifetimes
- Operator overloading
Those are major reasons why I chose Rust for the drm/asahi driver...
It sounds like Zig is trying to be "modern C"... but the whole point of R4L is to not get stuck with C!
All those things Rust has that Zig doesn't are important for the things I'm doing.
Destructors/RAII are fundamental to how the driver tracks and cleans up firmware structures safely and reliably when needed. If I had to write "defer" everywhere it would be a bug-prone mess...
Rust's amazing macros are how I deal with the firmware versioning differences while keeping the driver maintainable. In C you can sort of do that (poorly) with the preprocessor... but Zig doesn't have that either, so that's actually a step back from C, as far as I can tell...!
I don't think I really need to explain lifetimes/memory safety, that's the one thing everyone knows is different between the languages... I'll just say, I am certain I wouldn't have gone from "first render" to "stable accelerated Linux desktop" in 2 days without memory safety.
(continued)
I didn't know anything about Zig, so I decided to take a look today... and I'm not very impressed ^^;;
I learned that Zig does not have:
- Destructors
- Macros
- Lifetimes
- Operator overloading
Those are major reasons why I chose Rust for the drm/asahi driver...
It sounds like Zig is trying to be "modern C"... but the whole point of R4L is to not get stuck with C!
All those things Rust has that Zig doesn't are important for the things I'm doing.
Destructors/RAII are fundamental to how the driver tracks and cleans up firmware structures safely and reliably when needed. If I had to write "defer" everywhere it would be a bug-prone mess...
Rust's amazing macros are how I deal with the firmware versioning differences while keeping the driver maintainable. In C you can sort of do that (poorly) with the preprocessor... but Zig doesn't have that either, so that's actually a step back from C, as far as I can tell...!
I don't think I really need to explain lifetimes/memory safety, that's the one thing everyone knows is different between the languages... I'll just say, I am certain I wouldn't have gone from "first render" to "stable accelerated Linux desktop" in 2 days without memory safety.
(continued)