|
|
|
|
|
by wsve
897 days ago
|
|
"Kernel C" is the name given to the subset of C (read, Linux's flavor of C) that was formed by deciding which language features/compiler extensions they would/wouldn't use. Hardly a new or unsolvable problem. Benefits of C++ over Rust:
- Far easier and nicer to integrate with an enormous existing C codebase
- C semantics are much more similar to C++ than to Rust, so no need to do huge pattern redesigns
- No need to suddenly fight a borrow checker and prove lifetimes for a code base that isn't aware of them at all
- Interfacing with existing C code will require unsafe interop, which greatly reduces the benefit of Rust's primary selling point
- Transitions to C++ code will counterintuitively almost certainly introduce less bugs than rewriting in Rust, because you can do it in a much more piecemeal manner, and only do so in very disciplined way Why should they rewrite it in Rust? |
|
Also, the interop story with rust is equal or better than C++ in many areas at this point. Aside from tools like bindgen eliminating entire families of footguns, try doing something like registering a member function to a c callback, the way virtually every driver works. The rust equivalent in the extremely immature kernel dev trees are a bit ugly, but already much simpler than the idiomatic C++ equivalents. For additional fun, try and do it safely with a custom allocator or closures in a modern version.