4 ms·
>We need a new standardized, zero cost, cross language interop format functions on the ABI/memory level I don't think that's doable unless the underlying langu
by simias 6y ago
>We need a new standardized, zero cost, cross language interop format functions on the ABI/memory level
I don't think that's doable unless the underlying language already has the same ownership and lifetime guarantees as Rust does, otherwise these bindings have to protect against memory issues by effectively taking ownership of the data to garantee its lifetime, which is not zero cost.
I simply don't think that you can auto-generate zero-cost safe C or C++ bindings automatically.
- estebank 6y ago> I simply don't think that you can auto-generate zero-cost safe C or C++ bindings automatically. As stated, that's likely an accurate statement, but if you separate the requirements for the bindings the problem looks way more tractable: - auto-generate: I'm pretty positive that this point is only hard given the following, and I feel you would agree with that assessment, so I'll just focus on the other ones. - zero-cost: doing zero-cost ffi is the best option, but a lot of advanced constructs that people want to use cannot be well represented in that way because they rely on the internal consistency of the host language. That means that dynamically loading a library written in Rust might make it so that you can only interact with ADTs, trait objects and whitelisted provided traits on those ADTs, potentially only through trait objects. That's not zero-cost, but it is super powerful. ObjectiveC has lived its entire existence going through vtables and that has even enabled runtime introspection that was super useful. - safe: safety can be accomplished easily enough if you don't constrain yourself to zero-cost or if you put constraints on what is supported for zero-cost ffi. You could say that method calls on trait objects is safe, but type parameters are out of scope because ffi and monomorphization are not compatible. You could restrict yourself to either no borrows crossing ffi, or no mutable data (only internal mutability through trait methods) allowed. - C or C++: I would focus on other languages, personally. Having easy interop with Java, C#, Python and JavaScript would open opportunities that do not have anything to do with systems programming per-se, but that would make it more likely that the next numpy isn't written in pure C. - automatically: the need for extra annotations in either end of the interop simplifies part of the problem and might even help with documentation. Adding some light ownership information to APIs in non-Rust languages would be great for non-Rust users of those APIs.
- bee_rider 6y agoHey! Surely there's some Fortran left in some of the libraries that back NUMPY.