glhaynes 10 months ago

Cool! One thing Swift is really (maybe uniquely?) strong at is C/C++/Objective-C interop, including mixing "legacy" code with Swift and even replacing it file-by-file with minimal ceremony. Looks like this is aiming to bring a similar level of interop to Swift<->Java.

aaronbrethorst 10 months ago
  • pjmlp 10 months ago

    The reasoning being different though, back then Apple wasn't sure Objective-C would take off among Mac OS developer crowd, used to Object Pascal and C++, Java support and its high integration with OS APIs was a kind of Plan B.

    Objective-C was actually embraced by the community, only Java heads cared about the bridge, and it was eventually killed.

    I feel it was a lost opportunity, but what do I know.

koito17 10 months ago

This gives me flashbacks to the Objective-C / Java bridge [1] from over a decade ago. It makes me wonder how they are dealing with memory management when Java objects are being used from Swift (or Swift objects from Java). This was one (of various) issues that made using the Cocoa Java bridge a bit unpleasant.

I guess Swift has a lot less run-time dynamism going on, so it may not be too hard to translate Swift semantics to Java. Definitely interested to see how this unfolds over the next year.

[1] https://developer.apple.com/library/archive/documentation/Co...

wiseowise 10 months ago

Will be wildly ironic if Apple pulls uno reverse card and eats Kotlin on Android instead of the other way around.

  • jwells89 10 months ago

    If Swift were practical to use for Android app development, I would absolutely do so. I enjoy writing Swift more than I do Kotlin by a good measure and not having to wrestle with gradle and proguard would be a nice bonus.

  • fidotron 10 months ago

    This would happen in about five minutes if a SwiftUI port was included.

    Which ironically would be just like Flutter, totally bypassing any native UI.

    My gut feeling is both teams probably have a plan for steamrollering the other in the event of anti monopoly measures forcing each to accept the other store. I.e. it is conceivable you could launch the Play Store on iOS and run a significant proportion of Android apps through a compat layer.

  • pjmlp 10 months ago

    Except contrary to iOS, on Android the C and C++ surface is very small, and calling JNI is a huge performance bottleneck.

    Anyone that cares about performance on Android has to write the userspace logic directly in Java or Kotlin, and use Android IPC instead of JNI.

  • Alupis 10 months ago

    Outside of Apple's ecosystem, is anyone using Swift?

    Kotlin is growing in all areas, especially backend (being fully embraced by Spring/Spring Boot et al).

    • pjmlp 10 months ago

      Spring embraces all JVM languages that can bring them new customers.

      • Alupis 10 months ago

        They have gone hard on Kotlin. Very hard. For example, in all of Spring/Boot's documentation, you will find Java and Kotlin examples, but not other JVM languages.

        • pjmlp 10 months ago

          I am old enough to remember when Groovy had similar treatment by Spring.

        • wiseowise 10 months ago

          Because they’re most likely commercial partners with JetBrains.

  • daghamm 10 months ago

    Kotlin-Java interoperability is at a completely different level.

  • airstrike 10 months ago

    It will also be glorious