Re:Rust and C++ Interoperability in Chrome
by foota on Wednesday August 19, 2020 @04:13PM
(#24215696)
I think the issue is that rust unsafe means "does something sketchy" whereas even perfectly safe C++ would have to be annotated unsafe.
[ Parent
| on HN ]
Re:Rust and C++ Interoperability in Chrome
by est31 on Wednesday August 19, 2020 @06:29PM
(#24217539)
Rust unsafe doesn't mean "does something sketchy". It means "compiler I know what I'm doing". It's equivalent to casting raw C pointers. You are supposed to know what you are doing when doing that, but you will be on your own. It might still be perfectly safe, but the compiler can't tell.
Re:Rust and C++ Interoperability in Chrome
by foota on Wednesday August 19, 2020 @08:52PM
(#24218712)
Sure, but it does indicate something likely to be wrong, relative to normal rust code. If every C++ function is unsafe then it becomes less clear where the actually unsafe rust bits are.
Re:Rust and C++ Interoperability in Chrome
by est31 on Wednesday August 19, 2020 @10:18PM
(#24219219)
C++ has made it very painless to upgrade from C, by being (mostly) a superset. It's so painless that many codebases haven't really upgraded and it's common to see C-isms sprinkled around larger code bases. Some classes written decades ago can survive the years written in horrible outdated style. For some that might be a feature, but for the quality (or safety) of the code it isn't.
Yes, when there is too much unsafe in a Rust codebase then the unsafe label inflates and the safety guarantees aren't as good. But the conclusion of that shouldn't involve changing definitions of what's unsafe and what isn't, but using less unsafe overall.
Rust can interface with C++, but it isn't well suited for too intimate interfacing. That's not where its strengths lie.
Re:Rust and C++ Interoperability in Chrome
by foota on Thursday August 20, 2020 @02:37AM
(#24220507)
I think that's a different goal from what chrome is looking for. It sounds like they want to be able to use their utilities and other code written in C++ from within rust, not integrated on a macro level.