1. 4

  2. 1

    OT: I totally forgot this tag existed, it looks like the last use was 2 months ago. How are things going in the Swift world? Despite frequently running on Apple hardware, I deal very little with the ecosystem.

    1. 2

      The big thing right now in the Swift community seems to be waiting for Swift 1.2 to drop. It’s in beta alongside Xcode 6.3 (Swift releases ship alongside new versions of Xcode), and adds a bunch of features such as:

      • A conditional can now have multiple if-let optional unwrapping predicates, as well as normal boolean predicates. This is intended to alleviate an issue where if-let conditions are deeply nested in order to unwrap several optionals and do something if none of them are nil.
      let optionalA : T? = // ...
      let optionalB : T? = // ...
      let optionalC : T? = // ...
      // Before: 
      if let a = optionalA {
        if let b = optionalB {
          if someTest(a, b) {
            if let c = optionalC {
              doSomething(a, b, c)
      // After:
      if let a = optionalA, let b = optionalB where someTest(a, b), let c = optionalC {
        doSomething(a, b, c)
      • A stdlib Set datatype with value semantics, to go along with Array and Dictionary.
      • A couple of other additions to the standard library like a version of flatMap that flattens arrays and a Zip2 data type representing two sequences zipped together.
      • Static stored properties in classes.

      It also makes a bunch of changes to both the stdlib APIs and some of the semantics of the language.

      Performance of compiled code, stability of Xcode, and usability of the developer tools are also better than they currently are in Swift 1.1, although there is still a long way to go. I’m not sure what the Apple developer tools roadmap is after Xcode 6.3 is released, but since 6.0 dropped they have been working almost nonstop on Swift, so the language and ecosystem is still very much in flux.

      1. 2

        That first example of nested optional lets is totally fascinating. It’s straight out of the Handling Nil section of Tom Stuart’s excellent “Refactoring Ruby with Monads”. Or, canonically, Haskell’s do notation. I’d heard Swift picked up Maybe as “optional”, but it’s neat to see it in different syntax.