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

Swift, why I won’t go back to Objective-C

Swift, why I won’t go back to Objective-C

By Robert van Loghem

Since Apple introduced Swift at WWDC ’14, I’ve been using the new language steadily in my new projects and existing projects. At first it was a love and mostly hate relationship. Slow compiler, slow Arrays, cryptic error messages, Signal 11 galore... it was the worst. When version 1.2 came out, most of my hate of the immature language and tools vanished and finally the benefits compared to Objective-C became very clear to me.

Robert van Loghem has been programming since he was 13 years old in Turbo Pascal, after doing over a decade of backend development in Java, and some Scala, he started developing Objective-C iOS apps in 2010 for NS and a little bit of ProRail. Now in 2015 he’s doing 100% Swift at Suitsupply.


May 20, 2015

More Decks by CocoaHeadsNL

Other Decks in Programming


  1. S W I F T, W H Y I W

    O N ’ T G O B A C K T O O B J E C T I V E - C R O B E R T VA N L O G H E M - S W I F T G U Y @ S U I T S U P P LY T: @ S O U N D B I T E S E : R VA N L O G H E M @ S U I T S U P P LY. C O M
  2. A B O U T M E • Lots of

    backend in Java (’99) and some Scala • Actionscript/Javascript • Doing iOS since 2010 for NS, ProRail some small clients and now Suitsupply • Love road-cycling 100+km’s and tinkering with Bluetooth LE heart rate, power, cadence, speed, external displays
  3. M Y R U L E S • Let the

    compiler catch my mistakes • Concise • Immutability • It’s ok to be a little verbose • Good code does not need documentation • Refactor, refactor, refactor, … • Composition • Clear responsibilities • Embrace change
  4. M Y T O O L S • PaintCode •

    AppCode* • Crashlytics • parse.com • Cocoapods • Cocoacontrols • Dash • Sketch
  5. A B O U T S U I T S

    U P P LY • Doing instore sales apps on iPod Touches • Working on customer apps • Working on secret projects • need good people…who can’t go back to 
  6. “I started with Swift < 1.0 because I did some

    Scala in the past and it seemed to be the new Apple future”
  7. M A R M O T T E C R

    E A T E A C Y C L I N G A P P, T H A T U S E S S W I F T A N D B L U E T O O T H L E C O N N E C T I V I T Y 11:11 01:43 41 65 31.2 39.3 3 164 89
  8. L O V E • let vs var • Options:

    SomeClass?, .None, .Some(x) • if let x = y as? SomeClass • No more headers! • switch, case, where • Type inference • map, filter, reduce chaining • closures where you can remember the syntax • Less verbose • Named tuples • Generics
  9. H AT E • Weird compiler error messages • Slow

    compilation • Crashes… • if let { if let { if let }} nesting hell • Slow arrays and dictionaries • Symbolicated Swift crash logs
  10. “In december 2014 ~20% of the code in the NS

    Reisplanner Xtra consisted of Swift code”
  11. B E T W E E N < 1 .

    0 A N D 1 . 2 • Cumbersome but helpful syntax upgrades • private/public/internal access for properties • But after creating more Swift files the compiler slowed to a crawl… • Fail-able initialisers
  12. B U T W H AT A B O U

    T M Y T O O L S ? • AppCode is WAAAAY behind, so proper refactoring is a pain… • PaintCode catched up pretty quickly • So did Dash…
  13. M O R E L O V E • The

    compiler became fast (incremental) • if let a = b, c = d where a == • Nullability safety • Set • Default values
  14. R U L E S I A P P LY

    T O S W I F T D E V E L O P M E N T • Never ever use ! with optionals unless you REALLY know what you are doing it’s the main source of my crashes • Use if let all over the place • Use generics and embrace type inference and Swift’s type system in general • Let the compiler really help you…
  15. S O W H AT ’ S N E X

    T ? • FutureKit • NotificationObserverKit • Reactive Cocoa 3.0

  16. S W I F T , W H Y I

    W O N ’ T G O B A C K T O O B J E C T I V E - C T: @ S O U N D B I T E S E : R VA N L O G H E M @ S U I T S U P P LY. C O M