4 ms·
I hope Rust / Objective-C interop gets some more love soon. There are a number of pain points, including inconsistent wrapping styles (the "cocoa" crate impleme
by raphlinus 6y ago
I hope Rust / Objective-C interop gets some more love soon. There are a number of pain points, including inconsistent wrapping styles (the "cocoa" crate implements things like NSView as traits on id), autorelease pools always being a pain, and a fair amount of bloat from the msg_send! macro (a lot of which is boilerplate error handling).
Not exactly obj-C, but there are also problems two inconsistent ways of wrapping other macOS types: some (like the Metal crate) use foreign_types, while others use the TCFType mechanism. Among other things, these have two different meanings for "Ref" types, which can be very confusing.
So it's possible to get stuff done, but it doesn't feel nice. By contrast, the Rust/Windows world pretty well organized, with Peter Atashian's winapi providing a solid foundation, the wio crate being a good way to get ComPtr and other utilities, and Microsoft's com-rs coming soon as a standard way to do Rust-side implementation of COM interfaces.
- Klonoar 6y agoI experimented with this in cacao: https://github.com/ryanmcgrath/cacao https://github.com/ryanmcgrath/cacao I just need to get around to "finishing" it. I think most of the other approaches miss what people would realistically need out of ObjC/Rust interop, so... well, that's my hat in the ring.
- raphlinus 6y agoYup, that is a promising direction. I think a lot of my concern is around building a consensus and getting people on the same page.