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

Swift: Uncharted Territory

Swift: Uncharted Territory

Some introductory concepts lead to some in-depth discoveries about Swift.

Video: http://www.realm.io/2014/06/17/swift-unchartered-territory-swift-intro-and-internals/

3a0ae72b2f6bdc4476f1fcb63396e717?s=128

JP Simard

June 12, 2014
Tweet

More Decks by JP Simard

Other Decks in Programming

Transcript

  1. SWIFT UNCHARTED TERRITORY

  2. CHRIS LATTNER

  3. CHRIS LATTNER LLVM

  4. CHRIS LATTNER LLVM SWIFT

  5. CHRIS LATTNER LLVM SWIFT ! HANDSOME

  6. STUCK WITH ME JP Simard @simjp realm.io

  7. THIS TALK 1. Early, incomplete version of a language? 2.

    Buggy, pre-release compiler, IDE, OS? 3. Unreleased beta of presentation app? 4. Presenter who doesn't fully understand the language?
  8. WHAT COULD POSSIBLY GO WRONG?

  9. WHY SWIFT > OBJC? ▸ Type safety & inference ▸

    Closures ▸ Tuples ▸ Super-Enums ▸ Functional programming ▸ Generics
  10. Q: WHAT DOES IT LOOK LIKE?

  11. TYPE SAFETY & INFERENCE LIKE RUST & SCALA

  12. CLOSURES SWIFT CLOSURES ! OBJC BLOCKS

  13. TUPLES LIKE HASKELL & SCALA

  14. SUPER-ENUMS* *OK, NOT EXACTLY THE CORRECT TECHNICAL TERM

  15. FUNCTIONAL PROGRAMMING LIKE HASKELL, SCALA & MANY OTHERS

  16. GENERICS LIKE... UH... EVERY MODERN LANGUAGE!

  17. Q: WHAT HAPPENED TO MY BELOVED *

  18. ▸ concepts are still there: reference types and value types

    ▸ pointers still exist to interact with C APIs: UnsafePointer<T> ▸ C APIs are still usable:
  19. DEMO #1

  20. Q: HOW DOES IT ALL WORK?

  21. A: it barely does !

  22. SERIOUSLY, HOW DOES IT WORK? ▸ Swift objects are actually

    Objective-C objects* ▸ *Without any methods or properties... strange! ▸ Just like C++, Swift methods are listed in a vtable ▸ Swift properties are ivars with Swift methods ▸ ivars have no type encoding!!! ivar_getTypeEncoding(); // always NULL
  23. DEMO #2

  24. XCODE & TOOLS INTEGRATION ▸ Clang knows absolutely nothing about

    Swift ▸ Swift compiler talks to clang through XPC /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ usr/bin
  25. DEMO #3

  26. JAZZY GITHUB.COM/REALM/JAZZY A SOULFUL WAY TO GENERATE DOCS FOR SWIFT

    & OBJECTIVE-C
  27. LINKS () ▸ Official Swift website ▸ The Swift Programming

    Language Book ▸ WWDC Videos ▸ WWDC Sample Code ▸ Xcode 6 (and other resources) Apple Developer Account Required
  28. LINKS (!) ▸ This talk: github.com/jpsim/talks ▸ Jay Freeman's AltConf

    talk: debugging your (Swift) apps with cycript ▸ ObjC/Swift doc generator: github.com/realm/jazzy ▸ Evan Swick: Inside Swift ▸ Swift on StackOverflow
  29. THANK YOU!

  30. Meetup().questions?.askThem! JP SIMARD, @SIMJP, REALM.IO