Recorded – watch the full episode on YouTube.
Swift 5.3 adds support for Windows. Is it a new approach for Swift to be a wider, multi-platform language? Are we going to see Android, WebAssembly happening at some point?
Chris Lattner: I think that the day Swift was open sourced, the announcement included the desire for Swift to go to multiple different platforms, and Apple invested in doing the first Linux port to make that clear.
"There's a tremendous amount of things beyond getting
Intto work on Windows that I think is about making it real."
There's a big difference between an announcement when you say, "wouldn't it be great if somebody did some things sometime in the future," versus actually putting skin in the game, putting effort into it, and paying money to make something start to happen. I think that was a big part of the signaling that Apple did. And I think that's really fantastic.
The Windows port is really the work of many people, but, Saleem, who's now on the core team, is one of the people that really drove that. And that was a tremendous amount of work to make happen. And that it's not just about Swift the language working in Windows, but it's also about Foundation, a bunch of the other tools, debug information – there's a tremendous amount of things beyond getting
Int to work on Windows that I think is about making it real. And so I am thrilled to see that.
As for other ports, Swift does run on Android. I know for certain that there's Swift code running in production on Android devices. The issue there is that, two things, nobody has really stood up to support it and maintain it, and so that's just looking for somebody to help with that.
"Swift's integration with the Java object model and being able to import Java APIs, that's never been done. And I think that could be done. I think that could actually be really beautiful."
If there's somebody interested in that, I think they ask on the Swift dev forums, and a lot of people would stand up to help you along and help make that happen.
I think the second question though, is Android is a very Java or Dalvik centric world. And so Swift's integration with the Java object model and being able to import Java APIs, that's never been done. And I think that could be done. I think that could actually be really beautiful, or an integration with C#, things like this. I think that Swift has plenty of ability to model these type systems and things like this.
It's merely a huge amount of engineering work, but when done, I think that you can get a really interesting world where you could talk to all the Apple iOS APIs. You could then talk to all the random Java, both for Android, but also for Swift on the server would benefit from this. There's a lot of interesting things that would come out of this.
The biggest annoying thing about that is really garbage collection. And you'd have to decide there's some design decisions about how you want to interface with the Java garbage collector, and how you're going to manage all that kind of stuff.
"It's merely a huge amount of engineering work, but when done, I think that you can get a really, really interesting world where you could talk to all the Apple iOS APIs."
Paul Hudson: Well, how about Wasm because that's increasingly growing? We're seeing Rust working on Wasm, we've got C++ working on Wasm. Is Swift ever possible, do you think?
Chris Lattner: Oh yes, absolutely. I mean, the Wasm back-end generally goes through LLVM. So Rust and Swift, both are compiled through LLVM, and the Wasm port works by an LLVM back-end for Wasm. I thought I saw something about that existing, but I think it's one of these people who have done the first 90% of the work and not the last 90%.
Paul Hudson: So I seem to recall it being a hang-up around things like map rethrowing, because Wasm wasn't able to handle a particular language feature of Swift right now. And it would require Wasm to change, or somehow do some hacks around it, perhaps. But it wasn't as simple as LLVM will do the magic for us.
Chris Lattner: I'm not aware of anything at the LLVM level that
map() would be problematic for. So, I don't know. This is me not knowing.
This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.
SPONSORED ViRE offers discoverable way of working with regex. It provides really readable regex experience, code complete & cheat sheet, unit tests, powerful replace system, step-by-step search & replace, regex visual scheme, regex history & playground. ViRE is available on Mac & iPad.
Link copied to your pasteboard.