With Swift open sourced, what would it take to have it running on the JVM?

724 views Asked by At

I program in Objective-C and Swift primarily and understood Apple's announcing Open Source Swift by end of year as a move to make it available for backend programming as well. To quote Craig Federighi (SVP Engineering) in the keynote “We think Swift is the language we'll be doing application and systems programming”. The mention to systems programming and the mention that there will be libraries for Linux seems a clear indication on the path to using as a backend development language as well.

So my question relates to two possible paths that could take. On the one hand, Swift's page says that “Using the incredibly high-performance LLVM compiler, Swift code is transformed into optimized native code that gets the most out of modern hardware.” This would mean that it would have to be compiled for each target hardware I assume. Is this assumption correct?

On the other hand, if Swift was compiled to the JVM I assume it would make Swift's adoption much wider and faster because it could take advantage of the JVM's hardware independence.

I guess the point of my question is: are these two assumptions above correct? Would it even be possible to compile Swift to the JVM? If so, what advantages and disadvantages would it have over native code to each target hardware.

I am curious to understand if this is on the ballpark on how to think about this development for Swift.

1

There are 1 answers

0
StilesCrisis On

LLVM IR can be used as a platform-agnostic binary distribution method. Google does exactly this with PNaCl. http://www.chromium.org/nativeclient/pnacl/introduction-to-portable-native-client

I don't know if JVM provides advantages over LLVM IR but it's not the same as locking into one exact binary format.