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.

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

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

  5. 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?
  6. 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
  7. 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!
  8. 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.

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

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

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