We just recently open-sourced an early prototype of a library for interoperability between Java and Swift at GitHub - swiftlang/swift-java. Our goal is to make it possible to interoperate in both directions:
The library is a very early prototype of both directions, using macros and code generation for Swift → Java calling and the Foreign Function and Memory API (aka Project Panama) for Java → Swift. Everything about it is up for discussion and change. We’d love to talk through design ideas, use cases, and implementation sketches.
Speculation and dreaming:
Might this in fact open up possibilities in the future to develop Android apps in Swift, using swiftlang official support - using some UI framework built on top of Android for Swift
Fantastic work. Kudos to the entire team! C, Objective-C, Python, C++, and now Java interoperability.
Looking forward to see what we all can build on top of it. Java support was unexpected, but most wanted for me
Conversely, would it allow porting existing Mac or Android apps written in Java? I know of at least one application that's available on desktop and Android, but not iOS, because all of the logic is written in Java and would require a complete rewrite.
The fact that we may one day develop backend services with Spring Boot + Swift is making me supper happy and excited for what the future brings. Kudos to everyone involved with this project and thanks a lot for all of your efforts!
Out of curiosity: Is my understanding correct that it's not a big effort to try this out with Maven? The repository uses Gradle, which makes me wonder whether this was an arbitrary choice or were there some blockers which I do not foresee in switching to mvn as a build system.
It could. The JNI parts of the implementation should work on Android for Swift calling into Java libraries. Android doesn't support the newer Foreign Function & Memory APIs that we're using for Java calling into Swift, so we would need to bring up a JNI-based solution there to work on Android and older Java installations.
It was arbitrary. For primarily Swift code bases, I'd like us to make the library usable with SwiftPM. But if you're using Swift inside a mostly-Java ecosystem, integrating with both Gradle and Maven makes sense.
Nice, it'll be great to see some adoption of the libs so we can make sure it's ergonomic etc We're figuring out how and when to tackle android but it's certainly another very interesting use-case.
It was awesome seeing this announcement at the conference! I’d love to help out, and explore if we could extend this (in the future) to proper Kotlin bindings as well. My goal would be to eventually bring it to a place where it could be a more ergonomic alternative to Kotlin Multiplatform - really excited about the potential here!
Great to hear from you online as well! Was fantastic to catch up in person and I hope we can join efforts eventually over here
Please watch the repo and please feel free to pick up any of the pending issues or create new ones. Better interop with other JVM languages isn't a top priority, but if anyone in the community were to pick it up I'd be happy to support the work, so please stay in touch In the meantime there's a lot of work to be done with just plain Java/JNI/Panama
from my understanding, skip is a transpiler, it doesn't really makes interop between swift code and android code. It just rewrites all your swift code (and only a subset of the language is supported) to kotlin.