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

Jacob Schwartz: F-yeah Swift

1fa9cb8c7997c8c4d3d251fb5e41f749?s=47 Realm
September 24, 2015
12k

Jacob Schwartz: F-yeah Swift

1fa9cb8c7997c8c4d3d251fb5e41f749?s=128

Realm

September 24, 2015
Tweet

Transcript

  1. L O O K I N G B A C

    K O N A Y E A R O F U S I N G S W I F T: L E S S O N S L E A R N E D … ( S O R T O F ) @ I S O I P H O N E
  2. W H Y A M I H E R E

    ? • iOS dev since 2008 (ObjC/C++) • Using Swift exclusively for ~11 months (@glintinc) • I enjoy talks about what worked / what didn’t • I enjoy hearing personal experiences from devs, so I’m here to share some…
  3. @ I S O I P H O N E

    L O O K I N G B A C K O N A Y E A R O F U S I N G S W I F T: L E S S O N S L E A R N E D … ( S O R T O F )
  4. N O T E N O U G H T

    I M E F O R T H AT • Swift is a big language • I have < 10 minutes • I want to call out 4 things that greatly affect how I write code in Swift (vs ObjC)
  5. N O T E N O U G H T

    I M E F O R T H AT • These things made Swift productive for me • So— how do I feel after 11 months of working with the language…
  6. F—— Yeah! Swift!

  7. W H AT S T H E R E T

    O B E E X C I T E D A B O U T ?
  8. F—— yeah, Types!

  9. var selectedFilters = [String: [String]]() @property (strong, nonatomic) NSMutableDictionary *selectedFilters;

  10. F—— yeah, Immutability!

  11. in C++ more const correctness = more effort class Puter

    { void compute(obj *ptr); void compute(const Obj *ptr); void compute(Obj * const ptr); void compute(const Obj * const ptr); void compute(const Obj * const ptr) const; }; Swift var dateString = formatter.stringFromDate(date) let dateString = formatter.stringFromDate(date) vs
  12. F—— yeah, Properties!

  13. A particularly messy but illustrative property var responseRate: Double? {

    didSet { let percent = min(100, max(0, Int((responseRate ?? 0) * 100))) let baseString = NSLocalizedString("$0 Response Rate", comment: "PulseTabResponseRate") let percentString = "\(percent)%" middleLabel.text = baseString.stringByReplacingOccurrencesOfString("$0", withString: percentString) } }
  14. F—— yeah, Community!

  15. S E R I O U S M O M

    E N T : ( • Not everything about Swift is great • There have been challenges
  16. S E R I O U S M O M

    E N T : ( • Supporting iOS < 8 effectively impossible • Compilation slow • Strange compiler errors • Tools break often
  17. S E R I O U S M O M

    E N T : ( • Supporting iOS < 8 effectively impossible • Compilation slow • Strange compiler errors • Tools break often These are known issues. They don’t change the point of this talk
  18. Types! Immutability! Properties! Community

  19. S U M M A RY ( 1 / 2

    ) • Strong typing • Immutability • Properties • Community • Dense • Expressive • Fun
  20. S U M M A RY ( 2 / 2

    ) • Dense • Expressive • Fun • Productive
  21. For me, Swift has been productive by being dense, expressive,

    and fun (even though the tools suck some times) I N C O N C L U S I O N
  22. F—— Yeah! Swift! @ I S O I P H

    O N E