7 ms·
What’s the story for Rust-C++ interoperability these days? That’s what kills adoption. Most C++ devs I know like the idea of Rust, but no one is going to go rew
by abbefaria27 18d ago
What’s the story for Rust-C++ interoperability these days? That’s what kills adoption. Most C++ devs I know like the idea of Rust, but no one is going to go rewrite 30 years of working code. It needs to be something you can incorporate gradually.
- drop_star 18d agoya our codebase is 30m lines of c++
- afdbcreid 18d agoThere's an interop initiative by the Rust Foundation, there is a project goal to map the problem space, there was an effort to introduce an attribute (`#[rustc_splat]`) to allow calling overloaded functions, and there are various community-generated tools for more or less automated bindings generation.
- kibwen 18d agoRust's raison d'être is to improve the confidence of the security-critical parts of your system. You don't need to rewrite all 30M lines of code to benefit from it, you just need to identify the 1% of your codebase with the greatest attack surface (e.g. any internet-facing string parser), cordon that part of the codebase off with a C ABI, and then convert that part to Rust. This is similar to how Firefox incorporates bits of Rust into its own C++ codebase over time (e.g. for parsing URLs).
- nicoburns 18d agoThere's a huge push for this from the big companies adopting Rust. Google has been developing https://github.com/google/crubit https://github.com/google/crubit. The older cbdingen is still usable if more limited (it's what Firefox uses for some pretty involved interop).
- estebank 18d agoYou might want to take a look at https://github.com/hkalbasi/zngur https://github.com/hkalbasi/zngur Calling Rust from C++ seems to be more technically straightforward than the reverse.
- uncle_kostya 17d agoWhat we do at work is defined a clear boundary and use extern "C" functions in Rust to make them callable from C++, and the same for callbacks. Required some effort but we're happy with the result.