3 ms·
> For starters it needs to have classes But, Rust doesn't have classes. > It needs to have some sort of error handling But, Rust doesn't use exceptions, jus
by gpm 8y ago
> For starters it needs to have classes
But, Rust doesn't have classes.
> It needs to have some sort of error handling
But, Rust doesn't use exceptions, just algebraic data types (`Result`).
> It needs to support some basic data like std::vector
But, these aren't primitives, these are just std library constructs. Which is arguably an advantage, if you get a good FFI you can just use the other language's libraries directly.
A higher level FFI is a good idea, I think you're going to discover that the intersection of languages is surprisingly close to C though.
- IshKebab 8y agoRust has things that at a binary level are the same as classes, so they could easily be part of a cross-language ABI. And so what if std::vector isn't primative. It's an extremely common construct that should be part of a cross-language ABI. Hell, it's simpler than strings and they are part of the C ABI. This is one of those things that everyone is going to nay-say until someone actually does it. The same happened with webassembly. I remember when it was deemed impossible and PNaCl would never work etc. etc.
- msbarnett 8y ago> Rust has things that at a binary level are the same as classes, so they could easily be part of a cross-language ABI. They are not "at a binary level the same as classes" (whose classes? C++'s classes?), at least not the moment things like vtables get involved.
- int_19h 8y agoPresumably this would be classes in whatever sense the ABI would define them. Which could be defined in such a way that they can be mapped straightforwardly to Rust structs and traits.
- msbarnett 8y ago> Presumably this would be classes in whatever sense the ABI would define them. Which could be defined in such a way that they can be mapped straightforwardly to Rust structs and traits. Which would then not map straightforwardly to C++ classes, because the vtable pointer would be in the wrong spot. You can't have an ABI that makes two things that represent things in concretely different ways somehow resolve that inherent contradiction.