Production Swift

0ebf471a3ae8df42a84f93a7efbbdbd0?s=47 Ash Furrow
February 06, 2015

Production Swift

In this talk, I use my recent real-world experience with Swift as a case study in an evaluation of Swift's production readiness. Take advantage of the lessons we learned to make the best decisions about Swift in your project.

Video is up here: http://www.thedotpost.com/2015/02/ash-furrow-swift-in-production

0ebf471a3ae8df42a84f93a7efbbdbd0?s=128

Ash Furrow

February 06, 2015
Tweet

Transcript

  1. 2.
  2. 6.

    How is it different? • Static vs. Dynamic • Prefers

    immutability • Encourages functional programming • Safe (well, safer) • Experimentation via Playgrounds
  3. 10.

    Objective-C Interoperability • Interoperability comes at the cost of Swift’s

    purity • We loose a lot of safety • Don’t just add @objc because it’ll make code compile
  4. 12.

    Objective-C Hurts Me if (indexPath.section == 0) { if (indexPath.row

    == 0) { } else if (indexPath.row == 1) { 
 } else if ... } else if (indexPath.section == 1) { if (indexPath.row == 0) { } else if (indexPath.row == 1) { 
 } else if ... } else if ...
  5. 13.

    Pattern Matching switch (indexPath.section, indexPath.row) { case (0, 0): case

    (0, 1): case (1, 0): case (1, 1): default: // nop }
  6. 14.

    Pattern Matching case (let section, 0) where section % 2

    == 0: case (0, let row): case let (0, row) where validate(row):
  7. 15.

    Self-Evaluating Lazy Closures class MySweetViewController: UIViewController { lazy var button:

    UIButton = { let button = UIButton.buttonWithType(.System) // configure button return button }() }
  8. 16.

    And many more … enums closures tuples generics compile-time awesomeness

    saved a kitten from a fire went to highschool prom with me function currying functions are closures array.sort(<) better terroir immutability by default type inference discovered penicillin operator overloading clear mutability syntax native collections REPL multiple return types concise pattern-matching
  9. 18.

    Apple Tools • Xcode, clang, Playgrounds, SourceKit, code signing, frameworks

    … • All are unstable • Causes frustrations • Causes delays • Causes hair loss
  10. 23.

    Eidolon Problems • Enterprise code signing issues with Xcode 6.1

    • Compiler segfaults with optimizations enabled • Constant Xcode/SourceKit crashes • Unit testing problems
  11. 24.
  12. 25.
  13. 27.

    Eidolon Awesomeness • We helped pioneer a new way of

    writing iOS software • Created many new libraries, tools, and resources • Used others’ new tools and contributed bug reports and fixes • Learnt a tonne, shared with others
  14. 28.

    Apple Tools • Someday soon, these will be ready for

    everyday use • But not today • You will have unanticipated problems • There will be no known solutions or workarounds • Until then, use with caution
  15. 29.

    3rd Party Tools • CocoaPods 0.36 has support for Swift

    • Tremendous amount of open source effort • Pre-1.0, use with caution • Carthage is new but promising • Pre-1.0, use with caution
  16. 31.

    Making a Choice • What’s your aversion to risks? •

    How hard is your deadline? • Why are you building something? • How open is your team to learning a new language?
  17. 34.
  18. 36.

    Be Aware • Don’t be afraid to revisit your decision

    • It’s OK to switch back to Objective-C