Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Production Swift

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

Ash Furrow

February 06, 2015
Tweet

More Decks by Ash Furrow

Other Decks in Programming

Transcript

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

    immutability • Encourages functional programming • Safe (well, safer) • Experimentation via Playgrounds
  2. 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
  3. 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 ...
  4. Pattern Matching switch (indexPath.section, indexPath.row) { case (0, 0): case

    (0, 1): case (1, 0): case (1, 1): default: // nop }
  5. Pattern Matching case (let section, 0) where section % 2

    == 0: case (0, let row): case let (0, row) where validate(row):
  6. Self-Evaluating Lazy Closures class MySweetViewController: UIViewController { lazy var button:

    UIButton = { let button = UIButton.buttonWithType(.System) // configure button return button }() }
  7. 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
  8. Apple Tools • Xcode, clang, Playgrounds, SourceKit, code signing, frameworks

    … • All are unstable • Causes frustrations • Causes delays • Causes hair loss
  9. Eidolon Problems • Enterprise code signing issues with Xcode 6.1

    • Compiler segfaults with optimizations enabled • Constant Xcode/SourceKit crashes • Unit testing problems
  10. 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
  11. 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
  12. 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
  13. 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?
  14. Be Aware • Don’t be afraid to revisit your decision

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