Slashdot Mirror


Apple Releases Swift 3.0, 'Not Source-Compatibile With Swift 2.3' (infoworld.com)

An anonymous Slashdot reader quotes InfoWorld: "Move fast and break things," the saying goes. Apple does both with the 3.0 version of its Swift programming language...its first full point revision since it became an open source project... In a blog post detailing the full body of changes for Swift 3.0, Apple singled out the two biggest breaking changes. The first is better translation of Objective-C APIs into Swift, meaning that code imported from Objective-C and translated into Swift will be more readable and Swift-like. The bad news is any code previously imported from Objective-C into Swift will not work in Swift 3; it will need to be re-imported.

The other major change... Most every item referenced in the standard library has been renamed to be less wordy. But again, this brings bad news for anyone with an existing Swift codebase: Apple says "the proposed changes are massively source-breaking for Swift code, and will require a migrator to translate Swift 2 code into Swift 3 code."

Apple will provide migration tools in version 8.0 of their XCode IDE, "but such tools go only so far," notes the article, questioning what will happen to the Linux and Windows ports of Swift.

31 of 148 comments (clear)

  1. better now by goombah99 · · Score: 5, Insightful

    than later when there's a huge code base.

    --
    Some drink at the fountain of knowledge. Others just gargle.
  2. Breathes new life into old APIs by SuperKendall · · Score: 4, Informative

    I have a pretty decent amount of Swift and the change between this version and previous versions is a lot more to absorb than it has been in the past... the migrator tool does help though it seems like it doesn't do as much as it could (that may have changed from earlier betas though).

    However, whatever brief pain this brings upon us, is more than made up by the improvements Swift3 brings to the Cocoa API...

    Have you ever worked on an Api for a long time, and thought "if I could do this again I'd rename all this stuff, and structure this one thing differently..."

    Well that's one thing Swift3 did for Cocoa - there's basically a whole new name mapping overlay for Cocoa that makes lots and lots of calls much clearer, and also extensions that offer more Swift friendly API calls in some cases.

    And the nice thing is some of the mappings are algorithmic, so your own ObjectiveC code you call from Swift benefits from name tidying or simplification, which works out well because of naming conventions Cocoa has long had and almost all Cocoa programmers follow.

    There are also specially tweaked mappings to some parts where special cases made the automatic mapping not make sense, so it's like the whole API has had an overview and some re-thought applied.

    It is sad that Swift3 could not yet bring ABI stabilization (so you could ship binaries of libraries to other developers and have them work in future Swift updates). But hey, the upside there is that people that want to ship Swift libraries have to give you source - who doesn't want that!

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  3. One word: Courage. by PhrostyMcByte · · Score: 5, Funny

    The courage to move on, to do something new that betters all of us.

    The Swift 2.0 language is more than 12 months old. It has its last big innovation about 6 months ago. You know what that was? They deprecated prefix and postfix operations, they made it smaller. It hasn't been touched since then. It's a dinosaur. It's time to move on.

    1. Re:One word: Courage. by hcs_$reboot · · Score: 2

      The courage to prepare for the right job interview "you're swift 3? sorry we're looking for 2.3 people"

      --
      Slashdot, fix the reply notifications... You won't get away with it...
  4. welcome to python by nimbius · · Score: 4, Insightful

    where we have 5 versions, 3 syntax distinctions, and flipping through them like a rolodex while muttering "what in the name of god does this code need to run" is a time honoured tradition.

    --
    Good people go to bed earlier.
    1. Re:welcome to python by MSG · · Score: 3, Informative

      Python was initially released in January 1994, almost 23 years ago. Since then, some libraries have been deprecated, first producing warnings, and later being removed. That process gave users and developers time to update the code without completely breaking following an upgrade. Backward compatibility was reasonably well maintained until 3.0, which was released in parallel with 2.6. Python 2 is still maintained while developers port code to Python 3.

      That's a big contrast from Swift, which was initially released almost exactly 2 years ago, and made significant backward-incompatible changes without an interim version that retained compatibility. Python's not perfectly backward compatible, but it's a whole lot better than this.

    2. Re:welcome to python by h33t+l4x0r · · Score: 4, Insightful

      Python 2 is still maintained while developers port code to Python 3.

      That's one way to put it. Another way to put it would be:

      Python 2 is still maintained because developers aren't porting their code to Python 3.

      It's 9 years later, at some point Python is going to have to give up on Python 3 and move on to a Python 4 that is backwards compatible with Python 2.

    3. Re:welcome to python by Anonymous Coward · · Score: 3, Informative

      Python 2 is still maintained because the installed base of useful Python 2 code is extremely big. People are porting to 3, but it takes time.

      And the actual changes are much smaller in Python 3, here the new Swift is completely changing a lot of APIs without notice nor deprecated phase.

  5. Re:Lol by bug_hunter · · Score: 3, Insightful

    And thank goodness they do that.
    Otherwise we'd be on OS 9x on PowerPC.

    --
    It's turtles all the way down.
  6. Re:Garbage by lucm · · Score: 3, Insightful

    Nobody gets raises for being a cunt. Come up with a plan to fix this in a cost-effective manner, and maybe next time they'll pay attention.

    --
    lucm, indeed.
  7. Re:Swift is always doing non compat updates by pushing-robot · · Score: 5, Interesting

    The language just turned two years old, and they've been saying for a while that the language wouldn't be 'stable' until version 3.0.

    Nothing is perfect on day one, after all, and Swift borrowed a lot of terribly ugly library methods from Obj-C to make the transition easier. Cleaning all that up for 3.0 will cause some short-term headaches but make future code a lot less cumbersome.

    Hopefully from here on the changes will be relatively minor.

    --
    How can I believe you when you tell me what I don't want to hear?
  8. Re:Swift is always doing non compat updates by dynamo · · Score: 2

    Lol I have seen many projects waste so much time because of swift's BS incompatible updates to do critical things like making the ++ operator a compile error.

  9. Re:Garbage by stealth_finger · · Score: 4, Funny

    Nobody gets raises for being a cunt.

    Then how do the higher ups get their jobs?

    --
    Wanna buy a shirt?
    https://www.redbubble.com/people/stealthfinger/shop?asc=u
  10. Re:Swift is always doing non compat updates by Buchenskjoll · · Score: 4, Funny

    Nothing is perfect on day one, after all

    I was.

    --
    -- Make America hate again!
  11. Re:Swift is always doing non compat updates by Anonymous Coward · · Score: 3, Funny

    And it all went downhill from there

  12. Re:Then use Swift by goose-incarnated · · Score: 3, Interesting

    Since Swift is open source, it's already been ported to many platforms. It's on Linux (which Apple officially supported) and Windows and even Android now...

    So is DOSBox. Doesn't mean much. The reason it hasn't been forked is because there simply isn't enough interest in it from people with the technical ability to fork it.

    If you are ignoring Swift because of your irrational hatred of Apple, you are only hurting yourself and your future employability.

    I dunno hey - I soundly ignored iOS, Obj-C and all Apple development and it hasn't done anything to my employability at all. I expect similar by soundly ignoring Swift.

    But I do thank you for making it even easier for me to find work.

    Personally I'm not in competition with you - I do (and have done) s/ware development on more than a single manufacturers products. I'm flexible. The amount of non-Apple development work out there dwarfs the Apple-only development work. Hell, the Apple-only work being offered is so tiny I doubt it even makes a margin-of-error difference? Maybe four orders of magnitude difference? Less?

    --
    I'm a minority race. Save your vitriol for white people.
  13. Re:Swift is always doing non compat updates by uohcicds · · Score: 3, Insightful

    Yes. It's not like people weren't warned about this. The Swift 3 announcement at WWDC back in June made this very very explicit indeed, as indeed did swift.org from even earlier.

    --
    It's not you: I'm just this horrifically socially awkward with everybody.
  14. Re: Then use Swift by goose-incarnated · · Score: 2

    I have no doubt that you could still get a job writing in COBOL if you wanted to.

    I ignore COBOL for the same reason I ignored iOS-dev: there is no lack of opportunity without them. Lacking iOS (or COBOL) doesn't change my employability enough for me to even notice.

    --
    I'm a minority race. Save your vitriol for white people.
  15. Meanwhile, back in C land... by Viol8 · · Score: 2

    ... my Stevens unix systems programming book (which applies t to OS/X too) from the mid 90s is still mostly relevant today.

    1. Re:Meanwhile, back in C land... by west · · Score: 4, Insightful

      Well, C was created in 1972, so that did give them some 20+ years before stability...

  16. Re:Swift is always doing non compat updates by DavidRawling · · Score: 2

    Ah yes because

    DoSomething(i);
    i = i + 1;

    is so much better.

    ProTip: This is sarcasm.

  17. Re:The only breaking change worth having by brantondaveperson · · Score: 2

    Using whitespace to express indentation is completely retarded in any case. Editors should be smart enough to display code using whatever indentation style you prefer, and should save files with minimal whitespace inserted. Thus people get to look at their code however they prefer, and no-one ever has to worry about merging whitespace-only changes, because there would be no such thing. Quite how we've got this far, without anyone ever bothering to do this, is quite beyond me.

  18. This thread is full of anti-Apple haters by Anonymous Coward · · Score: 4, Informative

    Everybody whining here clearly hasn't written any Swift code and is only interested in bashing Apple. Maybe you should be asking what actual people using Swift think of this.

    Well, I'll tell you as one.

    - The Swift syntax changes are annoying to spend time on, but minor.
    - Apple's migration tool is helpful and makes fixing go fast.
    - It was no surprise or secret that the syntax was going to change. They said all this upfront and we all knew this was coming.
    - Swift on Linux and other platforms only started working less than a year ago. There is not as much code to transition.

  19. Re:Garbage by Feral+Nerd · · Score: 3, Funny

    Nobody gets raises for being a cunt.

    Then how do the higher ups get their jobs?

    They ingratiate themselves to the cunts by being dildos.

  20. Re:The only breaking change worth having by luis_a_espinal · · Score: 2

    Using tabs enables the viewer to view the code indentation with as much spacing as they see fit. That means on my X character wide ultra high res terminal, i can ensure that there is a noticable level of identation. People who don't get that tabs can be redefined to make formatting more legible for the person reading your code are assholes.

    Or you could say that in projects with a lot of people, it pays to force an indentation standard based on a universal number of spaces, a constant retained from revision to revision. Then when you, the generic you, do a diff in any tool, it will look exactly the same regardless of a user's editor setup.

    I'm sure there are people who will disagree and will put valid counter-arguments. I can only say that after doing this for a while and having to deal with disparate formatting of the same file in the same bloody branch (making diffs almost impossible to discern without some serious massage), then a standard spacing becomes a lifesaver.

    See, programmers are very talented, but also extremely opinionated. Sorry, most cannot do shit without having someone forcing some rules upon them. The amount of ego is just staggering, and almost everyone, when left to her devices reformats and shuffle shit on a file to fit her own needs without ever thinking "gee, I wonder if the next person who has to maintain this piece of code will be able to effectively discern logical/structural changes from formatting ones without involving file-massaging heroics.".

  21. Re: Then use Swift by BasilBrush · · Score: 2

    Yes, there's plenty of choices of languages for which there is lots of employment opportunities. So it comes down to what you enjoy doing.

    For me, I've done C & C++ and I certainly don't miss having seperate header files to maintain and include.

    Java? Who wants all that verbosity, and endlessly nesting braces.

    Swift is a breath of fresh air. It's rather like a statically typed Python, without the strange idioms and indent based blocks. And everything designed with the objective of limiting the likelyhood of creating bugs.

    It makes programming a pleasure again.

  22. And Thus the Reason for Swift 2.3 by rsmith-mac · · Score: 4, Informative

    What TFS doesn't do a good job of explaining is that with Swift 3, Apple has essentially forked the project into two parts. Besides the newer version 3, Apple is also continuing to develop/support Swift 2.x. The already-released Swift 2.3 is Swift 3's counterpart for developers who would like to stick with Swift 2.x code.

    Swift 2.3 is a minor update from Swift 2.2.1. The primary difference between Swift 2.2.1 and Swift 2.3 is that it is intended to be paired with Apple's macOS 10.12, iOS 10, watchOS 3, and tvOS 10 SDKs. It also updates the underlying LLVM and Clang versions to match with those in the Swift 3 compiler.

    I don't imagine Apple will support Swift 2.x forever. But for the time being, Swift 3 is only as source-breaking as you want it to be. Developers who need Swift 2 compatibility can roll on with 2.3.

    1. Re:And Thus the Reason for Swift 2.3 by OzPeter · · Score: 3, Funny

      What TFS doesn't do a good job of explaining is that with Swift 3, Apple has essentially forked the project into two parts.

      Stop confounding us with facts! I was halfway through sharpening my pitchfork when I saw your comment and now I'll also have to cancel that Amazon order for my torch oil.

      --
      I am Slashdot. Are you Slashdot as well?
  23. Re:Swift is always doing non compat updates by Brett+Diamond · · Score: 4, Informative
    The ++ operator is not the same as += 1 operation. For example,

    var a = 3
    let b = a++ * 3

    Now, I expect this type of code is the justification Apple is using to remove the operator; although there is no ambiguity, the line which sets b also sets a.

    I argue that prefix and postfix ++ and -- should have remained in Swift. Not only are they well defined, but they are a standard operator in almost all new languages and therefore convey their meaning to the application developer significantly better than += 1 or -= 1 ever could.

    For example, when reading code, ++i requires significantly less reading and parsing by the developer than i += 1 to convey the same idea.

  24. Re:Courage was the right world in the end by SuperKendall · · Score: 2

    That's just one example, the entire tech press has lost its shit over the jack being gone. Yes it takes a lot of courage to do something that the press hates En Masse (which they knew would happen) and in turn may drive away some customers - which brings us back around to Slashdot where a number of people said they wouldn't consider a device without a headphone jack.

    Making a change you think is better in he long run that may cost you customers today does take courage, you will never admit that but you know it is true which is why you are so fiercely denying it.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  25. Very easy transition by cerberusss · · Score: 2

    I'm working on a small mixed Objective-C/Swift project. The API was provided, and is in Objective-C so no changes there. The UI code (i.e. all view controllers) are all in Swift, and consist of about ~30 classes. Moving from Swift 2.3 to 3 was quite easy with the migration tool, and took me about two hours.

    --
    8 of 13 people found this answer helpful. Did you?