4 ms·
It’s clear that the value promise of Carbon is to make it attractive to port existing C++ applications to it. But how this is accomplished, article does not go
by miohtama 4y ago
It’s clear that the value promise of Carbon is to make it attractive to port existing C++ applications to it.
But how this is accomplished, article does not go into detail in this. Is there going to be ABI compatibility with C++? What are the features that make Carbon a better porting target than Rust?
- timbit42 4y agoRust is closer to the the type of languages we need to move to but Carbon makes it easier to port away from existing C++ software. If it's a new project, use Rust if you can. Use Carbon if you need to deal with C++. Rust can interoperate with C++ but with more difficulty.
- kirbyfan64sos 4y agoThe official webisite (https://github.com/carbon-language/carbon-lang https://github.com/carbon-language/carbon-lang) goes into better detail, but the gist is that you can basically #include C++ libraries and use their APIs as-is, without needing to resort to unsafe blocks or having to write more idiomatic wrappers.
- flumpcakes 4y agoThere is ABI compatibility insofar that Carbon will be able to integrate C++ at the AST level within the compiler. This is quite smart as you are basically getting ABI compatibility for free. Assuming you have the source code to the C++. I'm not sure how it will work with dynamic or proprietary libraries, but as I understand it that is already a technically unsolved ABI problem with C++.
- flumpcakes 4y agoRust will require a complete re-write or extensive work implementing a C-like interface for your C++ API. Carbon will be able to use C++ classes natively, including calling methods etc. I think Carbon will be a much better choice for extending a C++ project. Rust might be a good choice if you are able to start from scratch or the project has C bindings.
- stonemetal12 4y agoHow did the firefox team handle it? They have moved parts to Rust while the rest is still C++.
- azakai 4y agoFirefox is porting or replacing entire libraries. (The idea with Carbon is you could replace specific C++ classes or headers.)
- tormeh 4y agoWasn’t https://cxx.rs/ https://cxx.rs/ supposed to make writing C-bindings unnecessary?