News: 1600862833

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Swift tailored for Windows no longer folklore: Apple's programming language available for Microsoft OS

(2020/09/23)


A Google programmer has made tools for Apple's Swift programming language available to developers using Microsoft's Windows operating system, a move likely to rekindle hopes that Swift, open source since 2015, will become popular beyond the macOS and iOS ecosystems.

On Tuesday, Saleem Abdulrasool, a software engineer at [1]Google Brain who joined the Swift Core Team in January, announced the availability of a new set of downloadable [2]Swift toolchain images for Windows .

Abdulrasool has been spearheading the effort to bring Swift to Windows for more than a year and now feels that the various components involved – the compiler, the standard library, and core libraries like dispatch, Foundation, and XCTest – have reached a point where early adopters can try them out.

"With these core libraries and the flexible interoperability of Swift with C, it is possible to develop applications on Windows purely in Swift while taking advantage of the existing corpus of libraries on the Windows platforms," said Abdulrasool in [3]a post to the Swift blog.

The Swift team tipped its hand about Windows development back in January in a note from Apple's head of Swift development Ted Kremenek, and again in March when project developers discussed goals for Swift 5.3, which was released last week.

The debut of a [4]Windows-focused forum on the Swift discussion website argues that Swift on Windows is now a thing, alongside Swift on Linux.

Official tailored Swift for Windows support promised in 5.3 [5]READ MORE

Abdulrasool has posted [6]demo code for a Windows calculator app written in Swift as an example of the possibilities. And Readdle, maker of Swift-based cross-platform email app Spark, earlier this month, published [7]a post about its efforts to develop a Windows version of its email client using Swift.

Enthusiasm for Swift outside of the Apple ecosystem has surfaced periodically in recent years, only to die down again. In December 2019, IBM, [8]a booster of server-side Swift since 2016, [9]backed away from the language. In January 2020, server-side Swift-hosting biz Vapor Cloud said it would discontinue its service in February.

Setbacks aside, Google sees reason to support [10]Swift for TensorFlow code , as its TensorFlow developers explained in [11]a 2018 document . Swift, it turns out, has some features and characteristics that prove to be particularly useful for machine learning, such as [12]automatic differentiation . It's also significantly faster than Python when properly tuned.

Swift could see its reputation rise further still with the release of Swift 6.0, which doesn't yet have a specific timeline but should debut once the core team implements improved concurrency support and [13]a resource ownership model similar to [14]Rust's ownership system .

If Swift can match Rust's code safety potential, the language's more approachable syntax could help it win developers away from trendier Rust, and other high-performance languages like C and C++. That may also require high profile projects unaffiliated with Apple – the iPhone maker's imperious behavior and prickly relationship with third-party developers fosters a fair amount of suspicion that still colors perceptions about Swift. ®

Get our [15]Tech Resources



[1] https://research.google/teams/brain/

[2] https://swift.org/download

[3] https://swift.org/blog/swift-on-windows/

[4] https://forums.swift.org/c/development/windows/67

[5] https://www.theregister.com/2020/03/30/official_swift_programming_for_windows/

[6] https://github.com/compnerd/swift-win32/blob/ed4993f7cbb284a83ee77fcecdc2570cf24355e4/Examples/Calculator/Calculator.swift

[7] https://sparkmailapp.com/blog/swift-windows

[8] https://www.theregister.com/2016/09/28/swift_now_available_on_bluemix/

[9] https://www.theregister.com/2019/12/17/swift_ibm_pulls_back_open_source_priorities/

[10] https://www.tensorflow.org/swift

[11] https://github.com/tensorflow/swift/blob/master/docs/WhySwiftForTensorFlow.md

[12] https://github.com/tensorflow/swift/blob/master/docs/AutomaticDifferentiation.md

[13] https://github.com/apple/swift/blob/master/docs/OwnershipManifesto.md

[14] https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html

[15] https://whitepapers.theregister.com/

Elledan

If code safety is one's goal, then using Ada seems to offer both the more mature, tested, certified and compatible option out there. It also means using a language whose existence doesn't hang in the balance.

*Regretfully considers years spent using Objective-C*

karlkarl

>> *Regretfully considers years spent using Objective-C*

Don't regret it. I can potentially see Apple backtracking on Swift realizing that maintaining bindings to native libraries is too costly, they will potentially revert back to Objective-C. Your experience here will make you a decent manager (unless you enjoy coding)

The critical part in Objective-C is not the "Objective". It is the fact it can consume native C libraries.

This view may get a bit of dislike from avid Swift fans which is fair. However I strongly recommend them to not completely disregard Objective-C. Unless Apple adds a very small C-compiler to their Swift toolchain so that it can consume native C binaries, the future could very much revert back to Obj-C. Same goes for Rust and Go-lang to some extent. Even though Go is "kinda" close with its C preamble stuff.

Time will tell. Thus far time has strongly hinted at C compatibility being the winning formula. For example pick any two languages and try to get them to communicate directly without C somewhere in the mix!

Lee D

Today I discovered that I do not like Swift coding, or feel it necessary to exist as a different language.

It's C/C++ like, but with obscure little quirks that aren't intuitive:

self.window.rootViewController?.title

(What's the ? for? It's tricky to even Google it)

The Apple page pushes it as an ideal first language.

self.window.addSubviews(self.btnOperations)

_ = self.btnOperations.map {

$0.addTarget(self, action: Calculator.onOperationPress(_:_:),

for: .primaryActionTriggered)

}

And the people who write examples of it are not the best people to take progamming lessons from:

if Double(self.state.lhs) == 0.0 { break }

(protecting against a division-by-zero!)

About the only nice thing I can see is that UI primitives are one-liners to create, but that's true the second you include any UI library.

Does nobody make a decent, readable language any more?

Syntax updates

TimMaher

You wait until you try and migrate a Swift project across to the latest syntax.

Can’t do it in xCode 10? Nope.

Try in an earlier xCode 8? Bombs the converter.

Dig it out of a backup and recode it by hand? Yup. Days pass.

anononononono

Optionals (marked by ?) are discouraged in swift, which I like, but there's still a lot of them around, especially in UIKit

Using it in that context will return the title of the rootViewController if the rootViewController is present, or nil and won't fail.

You could replace ? with ! to force unwrap, but that will crash at runtime should the rootViewController be unset.

I prefer to use guard let to unwrap the optional if it's present and proceed through the code

I actually like this *quirk*, and it's pretty strict on types too, I wasn't a big fan of Swift for a long time and still liked my Obj-c, but having just delivered a project using swift 5+, written in a very short amount of time I'm very much converted. It's much harder to write bugs into your code unless you really try, and has a lot of improvements over obj-c. That project is published and has only had 1 type of crash related to my code, where I went around Swifts warnings about playing with unsafe mutable data, now fixed.

gnasher729

That question mark that you complain about just saves you a few lines of code. It’s handling optional values. After two days using Swift you’ll love it.

anononononono

A few lines of code at a time, it's nagging influence can goad you into refactoring a bit and eliminating chains of dealing with optionals

It's okay

Pascal Monett

It'll just be another Google Beta thing until Google gets bored of it and shuts it down in a few years.

Badly needed

disgruntled yank

Long ago, I read that some distinguished computer scientist, asked for his greatest contribution to the field, said, "I didn't invent another programming language." I saw this in an interview of Donald Knuth, but I forget the person to whom he attributed it--Alan Perlis, perhaps.

Re: Badly needed

Rob Gr

" but I forget the person to whom he attributed it--Alan Perlis, perhaps"

Probably not, as he was involved in the development of ALGOL.

Ummm...

Def

No.

Taylored to our needs

Rob Gr

One day I'll read an article about article about Apple's Swift without the, apparently obligatory, illustration of Taylor.

One day, just not today.

Re: illustration of shhh

Steve Davies 3

Is it too hard for those at El Reg to find a picture of... A Swift aka Apus apus or our Avian summer visitor.

I guess it is.

Green Jacket with a copy of the RSPB Guide to British Birds in the pocket.

Re: Taylored to our needs

Morten Bjoernsvik

I love your headlines :-)

Re: Taylored to our needs

Marketing Hack

@Rob Gr

Its Tay-Tay's world, you just live on it.

So, in summary....

Marketing Hack

A Google dev has been able to "Taylor Swift" for Windows?

Only a fool has no doubts.