Replies: 2 comments
-
I think this is a matter of priorities, although I'm pretty sure Rust interop is of long-term interest to the leads. Short-term, Carbon has interop with C++, and Rust has interop with C++, so C++ should bridge the gap. The middle-term goal would be to make that reasonably smooth. But direct Rust interop is likely to take a little more effort. It's just a matter of time & effort, but until we have reasonably complete C++ interop, I think it's too early to really think much about Rust interop. |
Beta Was this translation helpful? Give feedback.
-
Another thing to note is that Rust, as of today, still lacks a stabilized ABI. There are crates that offer solutions to this problem, namely |
Beta Was this translation helpful? Give feedback.
-
It would be very interesting if Carbon were interoperable with Rust as well as interoperable with C++. This would allow multilingual apps that link with both Rust and C++ libraries. There are high value libraries in both the C++ and Rust ecosystems that aren't duplicated in the other ecosystem. Nice if you can easily use any of these libraries in writing a program without creating shim layers. It would make Carbon a much more compelling language.
I don't mean that all the complexity of the Rust borrow checker need be imported into Carbon. Just that there is interoperability, so that you can operate on Rust data structures and call Rust functions. The responsibility for following the rules of mutability and lifetimes when calling Rust code could be in the hands of the programmer. These rules don't have to be automatically enforced by the compiler in order for Rust interoperability to be useful.
Maybe you are skeptical. Okay, right now you can call Rust from C++ by building a C shim layer around the Rust library. This shim layer is not guaranteed memory safe (because it is C). The programmer is responsible for memory safety. But you can do this, and there are certainly examples of this already in existence. Okay, I just want to drop the requirement to write a shim layer, and invoke Rust directly from code that can also invoke C++ code. Shim layers are a hassle to write and they have to be maintained as the Rust library changes.
Beta Was this translation helpful? Give feedback.
All reactions