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

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 Google …

  1. 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*

    1. karlkarl Silver badge

      >> *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!

      1. 0xTim

        You do know that Swift can interop with C without any issue and `swift build` can compile C code...right?

        1. karlkarl Silver badge

          Not really. Perhaps only in the same way Java can "interop" with C libraries and Ant can call a C compiler. This is in no way optimal if you are having to write a binding layer for every single one of these libraries.

          I mean direct interop. So that you can embed actual C code or include C headers in the Swift code directly like you can do with C++. Only then will you be able to avoid wasting time writing bindings.

  2. Lee D Silver badge

    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?

    1. TimMaher Silver badge
      Facepalm

      Syntax updates

      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.

    2. 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.

      1. ChrisMarshallNY
        Headmaster

        > Optionals (marked by ?) are discouraged in swift

        Really? I use them all the time. The discouraged ones, in my experience, are implicitly unwound optionals (!).

        It’s entirely possible for an experienced Swift programmer to write completely inscrutable code, but we’ve been able to do that in C for decades. In fact, I remember a yearly contest to generate the craziest one-line C program. Not sure if it’s still going on.

        Really, when it all boils down to it, ASM is the most readable language, because each step is so primitive, that it can’t get too crazy.

        1. anononononono

          Maybe I just interpret it like that, in that every time I forget one, the compiler gives me a warning, and that's it's much more aggressive over it than obj-c ever was.

          Also, in obj-c when swift was released, nullability flags were really pushed and I started noticing how much of our obj c code was using optionals, and I don't like the uncertainty of it all.

          I know it's somewhat easy to ignore, they just irk me.

    3. gnasher729 Silver badge

      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.

      1. 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

    4. Pascal Monett Silver badge

      It's okay

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

  3. disgruntled yank

    Badly needed

    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.

    1. Rob Gr

      Re: Badly needed

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

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

    2. Anonymous Coward
      Anonymous Coward

      Re: Badly needed

      Which kind of "scientist"? I classify them by did they, or did they not use drugs?

      I couldn't find it either, but if you don't mean sarcastically, that sounds like a Dennis Ritchie statement. I say that because he obviously never claimed the syntax his own and that C was just current procedural B with the speed of ASM.

      If said sarcastically or kind of like that, with a pure %100 guess, Stallman... definitely Stallman.

    3. Anonymous Coward
      Angel

      Re: Badly needed

      Couldn't find that quote but I found another, similar, one:

      "Actually I'm extremely glad to see the continuing development of languages, not only because programming languages are getting better and better in important ways, but also because such work soaks up a lot of people's energy-therefore computer scientists don't write papers that I would otherwise have to read, and I can get my books finished a lot sooner."

  4. Anonymous Coward
    Facepalm

    Ummm...

    No.

  5. Rob Gr

    Taylored to our needs

    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.

    1. Steve Davies 3 Silver badge
      Coat

      Re: illustration of shhh

      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.

    2. Morten Bjoernsvik

      Re: Taylored to our needs

      I love your headlines :-)

    3. Anonymous Coward
      Trollface

      Re: Taylored to our needs

      @Rob Gr

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

  6. Anonymous Coward
    Go

    So, in summary....

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

  7. RobLang

    I enjoyed the title and image, made me smile

    Thanks El Reg, I enjoyed that title and image. The story doesn't really affect me but I just wanted to pop in and show my appreciation.

  8. Charlie Clark Silver badge

    Performance

    It's also significantly faster than Python when properly tuned.

    While in general this is true because Swift compiles the code, when working with something like TensorFlow, about which the paragraph was based, this is likely to be less relevant as all the heavy lifting will be done using the compiled C++ code of TensorFlow.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like