We probably shouldn't implement a specific language just because we like aspects of that language. We should be focusing exclusively on the code being submitted.
What does "because we like it" mean? People like it because of nuanced reasons - namely the memory safety of Rust could bring about quite a bit more security and prevent bugs in things like drivers, and eventually targeted rewrites of parts of the kernel itself where this would bring the most benefit.
Any possible reason for using Rust could be explained away as "liking it." So your clarification isn't really clarifying anything. What you're probably meaning is that trivial personal preferences over things like syntax shouldn't be the primary reason to allow a language into the kernel, but if that's your concern then you didn't read the link posted by OP.
By using Rust in the Linux kernel, our hope is that:
New code written in Rust has a reduced risk of memory safety bugs, data races and logic bugs overall, thanks to the language properties mentioned below.
Maintainers are more confident in refactoring and accepting patches for modules thanks to the safe subset of Rust.
New drivers and modules become easier to write, thanks to abstractions that are easier to reason about, based on modern language features, as well as backed by detailed documentation.
More people get involved overall in developing the kernel thanks to the usage of a modern language.
By taking advantage of Rust tooling, we keep enforcing the documentation guidelines we have established so far in the project. For instance, we require having all public APIs, safety preconditions, unsafe blocks and type invariants documented.
Why Rust?
Rust is a systems programming language that brings several key advantages over C in the context of the Linux kernel:
No undefined behavior in the safe subset (when unsafe code is sound), including memory safety and the absence of data races.
Stricter type system for further reduction of logic errors.
Extensive freestanding standard library: vocabulary types such as Result and Option, iterators, formatting, pinning, checked/saturating/wrapping integer arithmetic, etc.
Integrated out of the box tooling: documentation generator, formatter and linter all based on the compiler itself.
Overall, Rust is a language that has successfully leveraged decades of experience from system programming languages as well as functional ones, and added lifetimes and borrow checking on top.
What does "because we like it" mean? People like it because of nuanced reasons
I'm suggesting the justification should be those nuanced reasons, not the desire you have for the actual thing.
To give a real world example;
You shouldn't buy something just because you like it. You should buy it because you like that it is safe. You should buy it because you like that it promotes safety. Not just because you like it.
I feel lots of recent Rust development has been largely about "We like this!" more so than "Well, $this is why Rust!" I'm explaining that I feel that this is an extension of that, and that we should exercise caution and do our best to reduce our susceptibility to naivety and ignorance.
5
u/BCMM Apr 15 '21
Can you expand on this?