back

by Philpax·1y ago·view on hn ↗
> If the intent was to interoyerate with c++ then not supporting the api is hostile. I have a lot of code using vector, if I have to convert that to arrays then you are hostile and worse that is new code which per the article makes it suspect

It's not hostile to not commit resources to integrating with another language. It might be shortsighted, though.

> d does support c++ abi. It seems almost dead now but it is possible.

That was made possible by Digital Mars's existing C++ compiler and their ability to integrate with it / borrow from it. Rust can't take the same path. Additionally, D's object model is closer to C++ than Rust's is; it's not a 1:1 map, but the task is still somewhat easier. (My D days are approaching a decade ago, so I'm not sure what the current state of affairs is.)

> realistically there are two c++ abis in the world. Itanimum and msvc. both are known well enough that you can imblement them if you want (it is tricky)

The raw ABI is doable, yeah - but how do you account for the differences in how the languages work? As a simple example - C++ has copy constructors, Rust doesn't. Rust has guarantees around lifetimes, C++ doesn't. What does that look like from a binding perspective? How do you expose that in a way that's amenable to both languages?

`cxx`'s approach is to generate lowest-common denominator code that both languages can agree upon. That wouldn't work as a language feature because it requires buy-in from the other side, too.

2 comments
I'm not arguing rust made the wrong decisions. I'm arguing the concequences of those decisions is hostile to C++ interoperability.
As long as Rust depends on GCC and Clang, it can surely take the same path.

I don't see Cranelift ever replacing them as the main backend.