-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The future of the Objective-C crate ecosystem #101
Comments
I've been watching this repo for a couple years now and no shade to @SSheldon but I think he could use a co-maintainer. I added mediocre objective-c support to rust-bindgen last year and used that to make uikit-sys which uses a bunch of the objc repos. I think more maintenance would really add to the macOS and iOS rust ecosystem. |
I've become disillusioned that much of this is meaningful/valuable. Originally I was really frustrated by Objective-C's lack of safety and I thought Rust could provide a much safer way to deal with that. But Swift had just been announced and has since gotten a ton more adoption and has incredible interop with Objective-C. Trying to write safe wrappers around Foundation and UIKit proved to be a massive undertaking, and I'm not sure why anyone would want to use them rather than just writing Swift. The widest adoption I've seen this crate ecosystem used for has been writing small unsafe shims to call Objective-C, like game devs use for graphics stuff. So writing safe wrappers over ObjC to make it fit Rust's model was a fun exercise for a while, but I can't see an endgame where using this is a better idea than writing Swift. It seems like the goal should be trying to minimize the amount of interaction that Rust and ObjC have rather than trying to drive more ObjC from Rust. |
Now that Swift has a stable ABI, I wonder if it's worth investigating directly bridging between Rust and Swift instead of relying on an Objective-C middle layer. Seems like it's possible with a little more compiler support: https://internals.rust-lang.org/t/using-swift-abi-from-rust/6307/22 |
There's actually been a start on this: rust-lang/rust#64582 as well as some initial layout for a swift-bindgen. |
I'm sad to hear that, but I've been there myself, it's fully understandable!
You're probably right in this, though this is by far not my primary objective - see below.
For me: Because Rust applications can be cross-platform.
This is actually exactly why I came here; because I want to help improve this situation, and these use cases safer! As an example, currently They also have their own EDIT: Ooops, I already mentioned the stuff about |
Definitely interesting, though I think there's merit in having both this library and the Swift bridging. Actually, would it even work with frameworks (like Foundation) originally written in Objective-C? Like, does there exist some "Swift-Foundation" framework shim that calls the Objective-C Foundation framework or what? Also, Swift requires at least OS X Mavericks 10.9, where Rust (and by extension, probably this library) would work on versions as low as OS X Lion 10.7, see rust-lang/release-team#2. And a minor note: For the few people that use it, the GNUStep support that this library has probably wouldn't work with Swift. |
@SSheldon I'm sorry to press on but at some point I and others need to know how to move forwards. It is totally cool if you consider this library feature complete and good enough as-is, in that case I'll just take my suggestions somewhere else / create a fork and move on. Wish you all the best! |
Hey @madsmtm! I don't feel that any of the open PRs currently merit the undertaking of users updating to a new breaking version of objc. But for example, I think the adoption of extern types could be a compelling reason, when they stabilize. If there are severe issues in objc or big improvements to be made, I am still interested in making those changes or reviewing and accepting PRs for them, but unfortunately I don't know of anything that currently rises to that level. This could be a reflection of the disillusionment I referenced before, and I'm sorry if that's the case. Perhaps I'm too conservative here, and I recognize this risks hurting the project by stifling innovation and discouraging contributions. It's hard for me to shift my mindset and think of a passion project in that way. If you have a vision for ways that the rust-objc ecosystem could be significantly better than it is currently, perhaps the best way forward is a fork. I'd love to see how all of your ideas can work together, and if there's enough demand from the rust community for these improvements perhaps that does mean it's time for me step down as objc maintainer. |
I fully understand and very much respect that you want to be conservative on updating But wanting to be conservative and only making major version bumps when absolutely required doesn't have to stifle innovation and discourage contribution! But no, I don't think I have many radical new ideas; I simply have a desire to fix soundness issues, make the library safer and make it more user friendly (better documentation and more examples is a big one in here), to in the end encourage a bigger ecosystem of crates using native macOS features. And by no means do I want to push you off the maintainer pedestal, it's been great having someone criticize my work so far, forcing me to formulate my reasoning (and actually discovering a flaw in some of my previous reasoning). So thank you! |
Alright, I yield, I'll take my suggestions elsewhere / create a fork. On a related note, how would you feel (a license is one thing, being considerate is another 😉) about me copying code snippets semi-verbatim / with a lot of inspiration from these crates to And how would you prefer attribution?
|
Alright, so I went and made a fork (still quite WIP), and merged the linked projects into that:
These crates contain fixes to a lot of upstream issues, you can see which ones in madsmtm/objc2#22. Unfortunately this requires some gnarly breaking changes, especially in how In addition, I've created two new I'm hoping to mature these crates over time, and start integrating them into some of the bigger projects (e.g. Thanks for your time! P.S. I'm sorry I haven't released the fork earlier, I hadn't decided on a name for all the crates yet, and didn't want to spend effort on a later crate-renaming. |
Oh, and a final thing, @SSheldon, then I won't bother you again for a while: Would you be willing to let me relicense your work under a dual MIT/Apache-2.0 license? Mostly to bring the crates more in-line with other Rust projects. I'd also like to remove the copyright notice from the MIT license (see rust-lang/rust@2a8807e), it would be nice if you could agree to that as well? I will of course be getting permission from other contributors before I make the final relicensing, see madsmtm/objc2#23. |
Belated answer, but: sort of. There is However, that is only for APIs that need an extra level of customization. Many of the APIs that become available when you At the binary level, APIs imported with the Objective-C importer do not have wrappers in All of the above is not specific to Foundation but also applies to other system frameworks. Footnotes
|
Yeah, I suspected this would be the case, which means that a Rust/Swift bridge would not be able to access Foundation APIs without doing essentially what |
EDIT: Okay, maybe I should read more carefully next time. Sorry. For anyone arriving at this thread, see this post further up about |
@Josh015 regarding a lack of updates to this crate over the last 2 years: are there any issues or bugs you would've liked to see addressed? |
No it's fine. I shot my mouth off before knowing the whole story and made an ass of myself. I'm sorry. |
😆 you all good man. I definitely haven't been very active here, just wanted to double check if there were some new issues I had missed! |
Introduction
Hey @SSheldon, I really like your collection of Objective-C crates:
objc
objc-encode
objc_exception
objc_id
objc-foundation
block
uikit
dispatch
)For better discoverability, maintainability, interoperability and usability (I will get to each of these), I would like to propose moving
objc-encode
,objc_exception
,objc_id
andobjc-foundation
(and maybeblock
anduikit
? But probably notdispatch
) into this repository.Discoverability
objc
(and by extension, it's dependencies) is popular and therefore easily discoverable, but we should strive to make the other crates receive some 👀 as well.As you noted in SSheldon/rust-objc-id#4 (comment):
As a very concrete example, I reimplemented almost the entirety of
objc_id
in #98 before realising that it existed.Maintainability
We might want to change
Sel
to be an opaque struct like most of the other types, or addUnwindSafe
bound toobjc_exception::try
- Making these changes are far easier to coordinate in a "monorepo".Also, if a better way to do a general thing is discovered, it can easily be applied everywhere - for example e86d26a (making stuff opaque structs instead of uninhabited enums) haven't been done in
objc_exception
(see SSheldon/rust-objc-exception#9).Finally, we'd only need to maintain stuff like CI in one place.
Interoperability
A lesser point, since
objc-encode
,objc_exception
,objc
andobjc_id
all form a dependency graph, butblock
for example needsClass
but has to create it's own type to not depend onobjc
.Also, it would be cool if
Id<Block, Owned>/Id<Block, Shared>
instead ofRcBlock
was a thing, that might be able to makeBlock::call
(+Block::call_mut
) andimpl FnMut/Fn for Block
safe.Usability
Users don't want to consider all the above crates, and whether they're fit for their use cases; e.g.
winit
reimplementsobjc_foundation::NSString
andobjc::rc::StrongPtr
, partially for historical reasons, but I suspect also because there haven't been a clear user story on how to to these higher-level things.fruity
exists for a reason; users want easy and safe. (Though I think @nvzqz took the wrong approach creating everything from scratch, I'll probably contact them at some point in the future to see if we can combine efforts).Concrete implementation
Make this a cargo workspace like
core-foundation-rs
, and move the crates in here (and maybe forobjc_id
just merge it into theobjc
crate?).Additionally, we should make some more cargo features to make it easy to choose which parts of the library to compile (e.g. an
rc
feature, amessage
feature and so on).I can make the PRs, but you'll have to mark the old repositories as archived and such.
Drawbacks and alternatives
Outtro
We can talk about it over a quicker medium if you prefer.
Also, if you're loosing interest in the project(s) and need a hand with the maintainer role, I'll gladly help out.
The text was updated successfully, but these errors were encountered: