4 ms·
I wonder if Zig [1] would be a better fit than Rust for the Linux Kernel. I haven't touched systems programming for a decade, but looking from the outside, it s
by giovannibonetti 5y ago
I wonder if Zig [1] would be a better fit than Rust for the Linux Kernel. I haven't touched systems programming for a decade, but looking from the outside, it seems like the author put even more effort towards C ABI compatibility than the Rust team.
[1] https://ziglang.org/ https://ziglang.org/
- matheusmoreira 5y agoIt would be really interesting to see Zig code in the kernel as well. It's certainly much closer to C than Rust.
- newaccount2021 5y agoZig is nowhere near mature enough to even be considered for kernel use.
- wyldfire 5y agoZig does seem like a closer match to C and so could have been better suited than Rust. It doesn't provide the same safety as Rust, so it's not as big of a payoff, though. Also, it's still fairly new relative to rust. The kernel project distributes several userspace utilities and new ones of those might be worth writing in Zig.
- Keyframe 5y agoZig is a cute but dead man walking project. Rust has gained traction and that's what ultimately matters.
- fsloth 5y ago"Dead man walking" is quite harsh. Zig is a one man passion project. Those are awesome. Rust is becoming and industrial scale tool. Those are awesome as well. However, each has their place. One man passion projects should not be used in anything mission critical. They totally should be used for fun, enjoyment and inspiration, and they may potentially grow to industry scale.
- Keyframe 5y agoA bit too harsh, I admit. Look at something in-between (project length / status-wise) like D. Similar story. Critical traction or a passion uphill road.
- fsloth 5y agoZig is still quite early. Not sure what eventual traction will be. As is there seems to be lots of love from lots of hacker / demo / oldschool types which may snowball into an industrial scale ecosystem in this or some parallel universe (i.e I would not bet either way just yet).
- est31 5y agoTo be fair, Rust has been a one man passion project for a long time as well.
- fsloth 5y agoYes, many projects have started like that. Projects can grow and mature. But there really is no crystall ball for that and you should only choose existing industry scale tools for production projects.
- est31 5y agoThere is lots of valid criticism of Zig. The fact that it's run by a single person is not. hostapd is maintained by a single human. They are responsible for about 69% of all commits in the git repo, 55% if you look at the last year. It's still the most widely deployed WiFi implementation of the world. https://www.openhub.net/p/hostapd/contributors/summary https://www.openhub.net/p/hostapd/contributors/summary
- fsloth 5y agoChanging WiFi stack is less of a problem than changing the implementation language. The perceived fragility of a an element of architecture should be inversely proportional to the effort of replacing the said module chosen. Large effort to replace an element (like the implementation languag) means the element should be of low fragility. This is not an argument against Zig or that it would not become an industrial scale tool. It just does not feel "lindyproof" yet for real work.
- nicklecompte 5y agoI think it’s worthwhile for researchers/hobbyists to develop toy kernels in Zig. Using it for Linux is just plain irresponsible. The bottom line is that, unlike Rust, Zig is unstable and unsuitable for production software. If real money or human lives depend on the software (as is the case with Linux) the choice of programming language should be somewhat conservative. It is worth looking at all the serious bugs in deficiencies in the upcoming 0.8 milestone: https://github.com/ziglang/zig/milestone/10 https://github.com/ziglang/zig/milestone/10 This is not a criticism of Zig, nor is it an insinuation that Zig is unable to write correct software. It is a reflection of that fact that compilers are very complex.
- ncmncm 5y agoThat is a compelling argument for no more C in Linux. But a compelling argument and $5 gets you a cuppa. Any argument that Rust, by contrast, would be OK in the kernel applies at least as strongly to C++, because C++ can read kernel C headers, where Rust will need hand-maintained equivalents. (Some automation is possible, but not enough.) The FUD Linus flings about C++ applies equally to Rust. (Anybody who says Rust is less complicated does not know Rust well at all.) But argument validity is not what carries the day: bad arguments tend to fail, but good arguments get pot luck. Ultimately, it comes down to biases of those with power to decide: C seems to them like a familiar quantity (full of risks, but favored risks), while Rust happens to be hot just now. In three years' time, Rust could very well not be so hot, and a new new thing might take over its social role. Zig could conceivably be that thing. (Zig isn't "safe", by Rust's definition, but by then something else may be more important; anyway the lack of safety does not disqualify C.) The new hotness will necessarily already exist today, to be mature enough to consider then, but not necessarily one that immediately comes to mind. Being different from Rust could be, by then, among the new hotness's attractive qualities, much as percieved differences from C++ boost Rust in some milieus.
- est31 5y ago> In three years' time, Rust could very well not be so hot, and a new new thing might take over its social role. Zig could conceivably be that thing. Zig is totally different from Rust. For starters, it does not have a safe subset of the language that prevents an entire class of bugs. It's slightly nicer C. There are plenty of languages like that.
- pdenton 5y agoI had no problems interfacing Ada with C many moons ago. It sure looks like the good old things are being forgotten, and often badly re-implemented.
- Yoric 5y agoZig definitely looks interesting, but it hasn't been nearly as much battle-tested yet, so it's a bit early to know whether it would be useful (or even usable) in the context. It is possible that opening the kernel to Rust would also open it to other system languages.
- fish45 5y agoI'll agree with other commenters that Zig is no where near mature enough for Linux yet. However, I definitely think that it will be a better fit than Rust in a few years. It's a fantastic C replacement.