from Hacker News

Swift 5.3 Will Be Supported on Windows and Additional Linux Distributions

by nan0 on 5/15/20, 11:51 PM with 300 comments

  • by judge2020 on 5/16/20, 3:24 AM

    > . It is hard to think that any Windows programmer would prefer Swift as a language over .NET languages, as many commenters pointed out on Reddit, but a port of Swift UI on Windows could be a game changer.

    Everybody would jump to Swift [for new projects] if it meant a cross-platform GUI framework.

  • by richard_todd on 5/16/20, 2:01 AM

    Whenever I've looked at examples on Swift on Linux in the past, the code always started with (hazy memory here) `use glibc` or similar, whereas the macOS version used a different library. So for example even just to produce a random number you had to use two completely different library functions imported with completely different names. All that to say: it's always felt to me like "cross-platform" for Swift means "the same syntax on a completely different platform." Has that changed, or will basic functionality on windows require a third completely different set of libraries?
  • by _bxg1 on 5/16/20, 12:22 AM

    This is really exciting. Every time I see something about Swift my thought process is "that looks like a lovely language but I don't build iOS/macOS apps, oh well". Maybe now I'll give it a real go.

    Fun fact: Graydon Hoare, the original inventor of Rust, now works at Apple on Swift.

  • by sime2009 on 5/16/20, 7:39 AM

    But why?

    Sure, there are people who want to tinker with it for fun, but outside of that what is the point in having Swift on Linux and Windows?

    You can't use it to build mac or iOS apps on Linux because the important libraries aren't there. There is no cross platform UI and Apple isn't likely to port and support theirs from macOS. If you are into servers then you have plenty of better languages options with established ecosystems. Maybe there are some command line apps on macOS which can now be ported to Linux/Window, but beyond that, what is the point? Where is Apple trying to go with this?

  • by myko on 5/16/20, 2:01 AM

    > It is not clear at the moment if Apple has any plans to port Swift UI to Windows and/or Linux

    It seems pretty clear they have 0 plans on doing that. They could've open sourced it in the first place, along with Combine.

    Not open sourcing Combine seems like a pretty short sighted decision to me.

  • by sakras on 5/16/20, 12:57 AM

    Also worth noting that Saleem has also been working on a wrapper of Windows GDI for Swift. While it's not a port of SwiftUI, it looks pretty similar.

    https://github.com/compnerd/swift-win32

  • by memco on 5/16/20, 1:58 AM

    This is good news to me! I've been very interested in Swift for a long time, but mostly work doing web dev so it would only be useful to me if I could run it on Linux and it initially didn't have a great support story. I know it has been able to run on some Linuxes for a while, but it just didn't appear to be a great ecosystem. Now, there's interesting stuff happening for both backend and fronted (https://twitter.com/lrz/status/1250644001604042752).
  • by xscott on 5/16/20, 3:32 AM

    > It is hard to think that any Windows programmer would prefer Swift as a language over .NET languages,

    It's not hard for me to think that. I've never been interested in .Net languages, and I write stuff for both Linux and Windows. If it was just Swift the language and compiler, and I had to wrap Win32 API calls by hand, I'd happily use it.

  • by brigandish on 5/16/20, 3:18 AM

    XCode (and hence most of the useful parts of using the Apple development ecosystem) as of v11.4 won't install on Macs running Mojave it's actually better, in my view, to use Mono/C# and things like Xamarin than start off with Swift and think you can port the other way and not be forced into upgrading your laptop for the privilege of writing apps for Apple systems.
  • by melling on 5/16/20, 12:51 AM

    I have a Swift Cookbook that I maintain on Github:

    https://github.com/melling/SwiftCookBook

  • by no_wizard on 5/16/20, 12:34 AM

    Wonder if some macOS only software will get ported to Windows once this happens. That if course is assuming there’s good support for the Windows APIs for building apps
  • by xvilka on 5/16/20, 1:02 AM

    They need objc2swift, something like c2rust[1], to speed up the legacy code upgrade. Transpiler and code refactoring tool, all while preserving the ability to run tests. Or, on the other side, c2rust should get an Objective C support as an input.

    [1] https://github.com/immunant/c2rust

  • by pier25 on 5/16/20, 2:24 AM

    I imagine the idea is basically writing Swift servers and sharing code between platforms.

    I could be wrong but I seriously doubt we will cross platform SwiftUI, UIKit, etc.

  • by badprose on 5/16/20, 3:56 AM

    This is extremely exciting for me. I started writing a toy application for my iPhone using SwiftUI a few months ago and have been very impressed by Swift (coming from C#). So far, SwiftUI has felt exactly like what I wished XAML would become.

    The documentation and error messages are a complete disaster though (https://nooverviewavailable.com/)

  • by iamcreasy on 5/16/20, 1:22 AM

    Quick question: Does it mean now we can write games on Windows using SDL + Swift, and it will run on MacOS without any change at all?
  • by tempodox on 5/16/20, 9:49 AM

    Good news. I'm feeling a strong reluctance against languages that only work on one platform.
  • by VexorLoophole on 5/18/20, 6:17 PM

    Sounds like great news! Am excited to see, where Swift will end. I am no developer but I like to code things and script tasks (at work that's even my job). Already tried many different languages. In the end I always used Python, because i feared that nobody can rewrite my code, if I write it in something more exotic.

    Out of interest I spend some evenings in swift (server-side) and it felt some kind of fresh air. Python feels so 'slugish' all the time. But I am worried, if swift will ever be 'useful' server-side.

  • by filleokus on 5/16/20, 9:11 AM

    I don't think this is evidence for a move to cross plattform UI apps, but I hope it's a move to make Swift more useful on the server side.

    As I've understood it, Foundation support is pretty good these days? But it would be cool if Apple ported even more frameworks that could be useful for server side applications. Recently I would have loved to have had AVFoundation available when doing some HLS parsing server side, for example.

  • by sandGorgon on 5/16/20, 5:09 AM

    Very interesting - so basically it will be versus React Native on Windows & Mac (using Typescript) https://microsoft.github.io/react-native-windows/

    Arguably people are already used to creating desktop apps using JS/Typescript using the Electron framework. React Native builds upon that.

    2021 is going to be interesting

  • by atarian on 5/16/20, 1:24 AM

    I hope they also add better builtins for HTTP. Last time I worked with Swift it was difficult to get a simple server up and running without a framework.
  • by andrewrothman on 5/16/20, 2:34 AM

    Off-topic, but I read the title as "Supported on Linux distributions including but not limited to Windows". Microsoft, you know what we want.
  • by brendenw on 5/17/20, 4:07 PM

    Surprised OP have overlooked the importance of adding Amazon Linux 2.

    That opens the door to seamless and full supported AWS Lambda functions in Swift.

  • by forrestthewoods on 5/16/20, 1:39 AM

    What’s the best resource to learn Swift? Should I grab a Bluetooth keyboard and go through Swift Playgrounds on iPad? Or is that more for children brand new to programming?
  • by mosselman on 5/16/20, 11:23 AM

    This looks good. I started learning Swift a few days ago because I want to play around with iOS and macos apps, so good to see I could use it on other platforms too.
  • by cutler on 5/16/20, 12:17 PM

    ... but not on OS X Mojave. What a joke.
  • by awinter-py on 5/16/20, 2:50 AM

    linux builds of ios apps would lead to general improvement in the state of build tooling for mobile (IMO)

    I take it this isn't that?

  • by ww520 on 5/16/20, 1:56 AM

    This is excellent news.
  • by nloladze on 5/17/20, 2:18 AM

    Huh, might finally get around to Apple garbage. Closing your users to one internal system with internal hardware works for speed and maintenance issues([with users] look at early Windows with it's struggles and blue screens despite it's prevalent use across various hardware systems. But it doesn't work with devs. Dude if I can't code your stuff or for your platform on my shitty little linux, I have zero interest in working on your platform or utilizing your tech stack.
  • by mister_hn on 5/16/20, 8:42 AM

    I will find swift interesting only once you can build apps without having a Mac
  • by eggsnbacon1 on 5/16/20, 7:54 AM

    So many comments suggesting different UI frameworks with varying levels of cross-platform support.

    Guys, I hate to say this, just use Java. Its fully cross-platform with a complete UI toolkit that looks native and isn't slow. You're not going to find anything else thats as complete or performant. Java has been focused on this niche forever.

    I bet you use Java GUI's all the time without even knowing it. Most of you every day. Tons of IDE's, database visualizers, and other dev tools are made with Java GUI's.

    Every Jetbrains tool, DBeaver, DB Visualizer, MySQL Workbench, other stuff I'm too lazy to look up. If you have a tool thats not web with a big UI, its Electron or Java 90% of the time.