News for hackers. Stuff that matters.
Re:Linux kernel in-tree Rust support by zozbot234 on Saturday July 11, 2020 @06:03AM (#23800886)
Rust integrates easily with C because it's explicitly designed to fall back to the C ABI for external linkage. Whereas writing C++ with any C++-specific features (hence, any "Modern", guidelines-compliant C++ at all) brings its own bespoke ABI into the picture, that's supposed to be stable but really is not and that one can't easily interoperate with from C. That's a huge non-starter in kernel dev.
Re:Linux kernel in-tree Rust support by bonzini on Saturday July 11, 2020 @06:06AM (#23800900)
Not really, both in Rust and in C++ the C-compatible parts have to be marked explicitly as extern "C". Even the syntax is the same.
Re:Linux kernel in-tree Rust support by zozbot234 on Saturday July 11, 2020 @06:17AM (#23800945)
C compatibility is marked the same way, but it's not idiomatically used the same way in C++ and Rust. In C++, being C compatible means essentially writing C and for everything else you're expected to rely on the "not really stable" C++ ABI whereas Rust does not even try to give you a stable ABI between stuff that's not part of pretty much the same build. Despite that, you're free to mix C-like and Rustic code in the same crate because the crate is literally the translation unit in Rust.
Re:Linux kernel in-tree Rust support by bonzini on Saturday July 11, 2020 @06:26AM (#23800981)
ABI stability doesn't matter for the kernel since it doesn't have a stable ABI either. You can write a C++ core and C wrappers for C++ classes just fine, the same as what you do in Rust.
Re:Linux kernel in-tree Rust support by wwright on Saturday July 11, 2020 @08:30AM (#23801697)
I’m a huge Rust fan, but this is a misrepresentation of C++. You can definitely use the vast majority of modern C++ features while also integrating with a C codebase (exotic control flow such as exceptions and coroutines are definitely dangerous, though).