-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update C++ interop goal #193
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks really good to me. I included a few suggestions that occurred, but I'll defer to you whether they're worth further changes, @tmandry.
@@ -39,7 +39,7 @@ Roughly speaking, there are three axes to adoption of memory safety: Social, Tec | |||
|
|||
For example, safety has become more socially desirable in many technical communities over the years, which has led to the development of mitigation measures and the adoption of languages like Rust. This has come partly as a result of the recognition of the economic costs of memory safety vulnerabilities. | |||
|
|||
For C/C++ this has led to an improvement along the technical front in terms of automated checking, in both static and dynamic tooling. However, this protracted effort has also revealed the limits of such an approach without language changes. While there have been growing calls for C++ to adopt memory safety features,[^safe-cpp] they have not gained traction within the body that controls the C++ standard for a combination of structural, technical, social, and economic reasons.[^corentin-profiles] The cost to adopting such features in C++ is too high for a combination of technical, social, and economic reasons. | |||
For C/C++ this has led to an improvement along the technical front in terms of automated checking, in both static and dynamic tooling. However, this protracted effort has also revealed the limits of such an approach without language changes. While there have been calls for C++ to adopt memory safety features,[^safe-cpp] they have not gained traction within the C++ standards body for a combination of technical, social, and economic reasons.[^corentin-profiles] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some would argue that safety profiles are addressing the safety issues, but the approach is fundamentally different to Rust, so perhaps it would be more accurate to say that the standards body has reviewed a proposal for evolving the language to add a Rust-like safe-by-construction subset and is currently opting to pursue a previously proposed, less-invasive alternative in an attempt to speed and simplify adoption, but which does not provide guarantees against undefined behavior or data races that are core to Rust's value proposition.
|
||
The fact that all of these options exist and undergo active development is a testament to the value developers see in Rust adoption. However, they leave out a large portion of production use cases today: Projects that make rich use of an API in a language like C++ where comparatively limited interop support exists for Rust, and that link in enough code to make rewriting infeasible. | ||
|
||
Furthermore, the limitations of current interop tooling are not simply a matter of adding features. Many of them stem from a mismatch in the expressiveness of the two languages along various axes. As one example, C++ and Java both support overloading while Rust does not. In some cases this mismatch is broadly accepted as a missing feature in Rust that will be added in time. In others, Rust's lack of expressiveness may be considered a feature in itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably worth calling out a few of these differences:
- Rust's different approach to inheritance (or perhaps the orientation towards composition)
- Generics vs templates
- Value semantics and default relocatability
Change the title to reflect that we are not actually solving the problem yet and emphasize calling C++ from Rust, since that is where many of the hardest problems lie.
Generalize the wording a bit around incremental adoption in large codebases, since the problems apply equally to any project that needs to call a rich C++ API.
Add a design axiom:
cc @baumanj