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

The Maturation of Swift

The Maturation of Swift

In 2018, Swift has stretched its wings into a truly widespread language. Join me as we take a look at how mobile apps, servers, functions, and even data science can be written in one language.

David Okun

June 11, 2018
Tweet

More Decks by David Okun

Other Decks in Programming

Transcript

  1. @dokun24
    @mccoyjus

    View full-size slide

  2. @dokun24
    @mccoyjus

    View full-size slide

  3. @dokun24
    @mccoyjus

    View full-size slide

  4. @dokun24
    @mccoyjus

    View full-size slide

  5. @dokun24
    @mccoyjus

    View full-size slide

  6. @dokun24
    @mccoyjus

    View full-size slide

  7. @dokun24
    @mccoyjus
    Objective-C

    View full-size slide

  8. @dokun24
    @mccoyjus
    Node.js
    Objective-C

    View full-size slide

  9. @dokun24
    @mccoyjus
    Java
    Node.js
    Objective-C

    View full-size slide

  10. @dokun24
    @mccoyjus
    Python
    Java
    Node.js
    Objective-C

    View full-size slide

  11. @dokun24
    @mccoyjus
    The History of Swift

    View full-size slide

  12. @dokun24
    @mccoyjus
    The History of Swift
    • June 2014 - Swift is released

    View full-size slide

  13. @dokun24
    @mccoyjus
    The History of Swift
    • June 2014 - Swift is released
    • June 2015 - Swift on Linux is announced

    View full-size slide

  14. @dokun24
    @mccoyjus
    The History of Swift
    • June 2014 - Swift is released
    • June 2015 - Swift on Linux is announced
    • December 2015 - swift.org goes live

    View full-size slide

  15. @dokun24
    @mccoyjus
    The History of Swift
    • June 2014 - Swift is released
    • June 2015 - Swift on Linux is announced
    • December 2015 - swift.org goes live
    • March 2016 - First Linux build available

    View full-size slide

  16. @dokun24
    @mccoyjus
    The History of Swift
    • June 2014 - Swift is released
    • June 2015 - Swift on Linux is announced
    • December 2015 - swift.org goes live
    • March 2016 - First Linux build available
    • June 2016 - Kitura at WWDC

    View full-size slide

  17. @dokun24
    @mccoyjus
    The History of Swift
    • June 2014 - Swift is released
    • June 2015 - Swift on Linux is announced
    • December 2015 - swift.org goes live
    • March 2016 - First Linux build available
    • June 2016 - Kitura at WWDC
    • October 2017 - Kitura 2.0

    View full-size slide

  18. @dokun24
    @mccoyjus
    Python
    Java
    Node.js
    Objective-C

    View full-size slide

  19. @dokun24
    @mccoyjus
    Objective-C

    View full-size slide

  20. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS

    View full-size slide

  21. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS
    • Smalltalk + C

    View full-size slide

  22. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS
    • Smalltalk + C
    • “Easy” interoperability with C++

    View full-size slide

  23. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS
    • Smalltalk + C
    • “Easy” interoperability with C++
    • Created in 1981

    View full-size slide

  24. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS
    • Smalltalk + C
    • “Easy” interoperability with C++
    • Created in 1981
    • Licensed by NeXT in 1988

    View full-size slide

  25. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS
    • Smalltalk + C
    • “Easy” interoperability with C++
    • Created in 1981
    • Licensed by NeXT in 1988
    • GCC extended to support it

    View full-size slide

  26. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS

    View full-size slide

  27. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS
    • Then…Clang and support for LLVM

    View full-size slide

  28. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS
    • Then…Clang and support for LLVM
    • iOS developers’ first choice

    View full-size slide

  29. @dokun24
    @mccoyjus
    Objective-C’s Place In iOS
    • Then…Clang and support for LLVM
    • iOS developers’ first choice
    • Still focused on manual memory management via
    reference counting

    View full-size slide

  30. @dokun24
    @mccoyjus
    2014

    View full-size slide

  31. @dokun24
    @mccoyjus
    2014
    • Craig Federighi announced
    Swift

    View full-size slide

  32. @dokun24
    @mccoyjus
    2014
    • Craig Federighi announced
    Swift
    • A focus on functions as first
    class objects

    View full-size slide

  33. @dokun24
    @mccoyjus
    2014
    • Craig Federighi announced
    Swift
    • A focus on functions as first
    class objects
    • Type-safety, automatic memory
    management

    View full-size slide

  34. @dokun24
    @mccoyjus
    if !NSUserDefaults.standardUserDefaults().boolForKey("copyAndPasteEnabled") {
    NSOperationQueue.mainQueue().addOperationWithBlock { () -> Void in
    UIMenuController.sharedMenuController().setMenuVisible(false, animated: false)
    }
    }

    View full-size slide

  35. @dokun24
    @mccoyjus
    Swift 2

    View full-size slide

  36. @dokun24
    @mccoyjus
    Swift 2
    • Focus on basic language needs
    • try
    • throw
    • catch

    View full-size slide

  37. @dokun24
    @mccoyjus
    Swift 2
    • Focus on basic language needs
    • try
    • throw
    • catch
    • Protocol extensions

    View full-size slide

  38. @dokun24
    @mccoyjus
    Swift 2
    • Focus on basic language needs
    • try
    • throw
    • catch
    • Protocol extensions
    • Open source announcement

    View full-size slide

  39. @dokun24
    @mccoyjus
    Swift 3

    View full-size slide

  40. @dokun24
    @mccoyjus
    Swift 3
    • Focus on stability, ABI (application binary interface)

    View full-size slide

  41. @dokun24
    @mccoyjus
    Swift 3
    • Focus on stability, ABI (application binary interface)
    • The great NS removal

    View full-size slide

  42. @dokun24
    @mccoyjus
    Swift 3
    • Focus on stability, ABI (application binary interface)
    • The great NS removal
    • NSUserDefaults -> UserDefaults

    View full-size slide

  43. @dokun24
    @mccoyjus
    Python
    Java
    Node.js
    Objective-C

    View full-size slide

  44. @dokun24
    @mccoyjus
    Python
    Java
    Node.js
    Swift

    View full-size slide

  45. @dokun24
    @mccoyjus
    Node.js

    View full-size slide

  46. @dokun24
    @mccoyjus
    Node.js

    View full-size slide

  47. @dokun24
    @mccoyjus
    Node.js
    • It’s fine

    View full-size slide

  48. @dokun24
    @mccoyjus
    Node.js
    • It’s fine
    • Accessible to all

    View full-size slide

  49. @dokun24
    @mccoyjus
    Node.js
    • It’s fine
    • Accessible to all
    • Tons more I/O based performance

    View full-size slide

  50. @dokun24
    @mccoyjus

    View full-size slide

  51. @dokun24
    @mccoyjus

    View full-size slide

  52. @dokun24
    @mccoyjus

    View full-size slide

  53. @dokun24
    @mccoyjus

    View full-size slide

  54. @dokun24
    @mccoyjus

    View full-size slide

  55. @dokun24
    @mccoyjus

    View full-size slide

  56. @dokun24
    @mccoyjus
    Kitura - The Swift RESTful API
    Framework

    View full-size slide

  57. @dokun24
    @mccoyjus
    Kitura - The Swift RESTful API
    Framework
    • Written just like Express.js

    View full-size slide

  58. @dokun24
    @mccoyjus
    Kitura - The Swift RESTful API
    Framework
    • Written just like Express.js
    • Works on macOS and Linux

    View full-size slide

  59. @dokun24
    @mccoyjus
    Kitura - The Swift RESTful API
    Framework
    • Written just like Express.js
    • Works on macOS and Linux
    • Front-end templating

    View full-size slide

  60. @dokun24
    @mccoyjus
    Kitura - The Swift RESTful API
    Framework
    • Written just like Express.js
    • Works on macOS and Linux
    • Front-end templating
    • ORM capabilities

    View full-size slide

  61. @dokun24
    @mccoyjus
    Kitura - The Swift RESTful API
    Framework
    • Written just like Express.js
    • Works on macOS and Linux
    • Front-end templating
    • ORM capabilities
    • Client SDK generation

    View full-size slide

  62. @dokun24
    @mccoyjus
    import Kitura
    let router = Router()
    router.get("/") { request, response, next in
    response.send("Hello world")
    next()
    }
    Kitura.addHTTPServer(onPort: 8080, with: router)
    Kitura.run()

    View full-size slide

  63. @dokun24
    @mccoyjus
    Kitura Runs On

    View full-size slide

  64. @dokun24
    @mccoyjus
    Kitura Runs On
    • Cloud Foundry

    View full-size slide

  65. @dokun24
    @mccoyjus
    Kitura Runs On
    • Cloud Foundry
    • Docker

    View full-size slide

  66. @dokun24
    @mccoyjus
    Kitura Runs On
    • Cloud Foundry
    • Docker
    • Kubernetes

    View full-size slide

  67. @dokun24
    @mccoyjus
    Python
    Java
    Node.js
    Swift

    View full-size slide

  68. @dokun24
    @mccoyjus
    Python
    Java
    Swift
    Swift

    View full-size slide

  69. @dokun24
    @mccoyjus
    Java

    View full-size slide

  70. @dokun24
    @mccoyjus
    Cloud Functions / FaaS

    View full-size slide

  71. @dokun24
    @mccoyjus
    Cloud Functions / FaaS
    • AKA Serverless

    View full-size slide

  72. @dokun24
    @mccoyjus
    Cloud Functions / FaaS
    • AKA Serverless
    • Serverless is…just another server

    View full-size slide

  73. @dokun24
    @mccoyjus
    Cloud Functions / FaaS
    • AKA Serverless
    • Serverless is…just another server
    • Focus on your functions

    View full-size slide

  74. @dokun24
    @mccoyjus
    FaaS Languages

    View full-size slide

  75. @dokun24
    @mccoyjus
    FaaS Languages
    • Java
    • Python
    • Node.js
    • Go
    • Ruby
    • Scala
    • Swift

    View full-size slide

  76. @dokun24
    @mccoyjus
    The Key of FaaS

    View full-size slide

  77. @dokun24
    @mccoyjus
    The Key of FaaS
    • Don’t worry about your server

    View full-size slide

  78. @dokun24
    @mccoyjus
    The Key of FaaS
    • Don’t worry about your server
    • Worry about your code

    View full-size slide

  79. @dokun24
    @mccoyjus
    struct Record: Codable {
    var name: String
    var office: String
    }
    enum RecordError: Error {
    case newRecordError
    }
    func main(input: Record, respondWith: (Record?,
    RecordError?) -> Void) {
    let newRecord = Record(name: “David”, office: “IBM”)
    respondWith(newRecord, nil)
    }

    View full-size slide

  80. @dokun24
    @mccoyjus
    Python
    Java
    Swift
    Swift

    View full-size slide

  81. @dokun24
    @mccoyjus
    Python
    Swift
    Swift
    Swift

    View full-size slide

  82. @dokun24
    @mccoyjus
    Python

    View full-size slide

  83. @dokun24
    @mccoyjus
    Python

    View full-size slide

  84. @dokun24
    @mccoyjus
    Python
    • The Data Science Language

    View full-size slide

  85. @dokun24
    @mccoyjus
    Python
    • The Data Science Language
    • Meant for heavy computation

    View full-size slide

  86. @dokun24
    @mccoyjus
    Python
    • The Data Science Language
    • Meant for heavy computation
    • Focused on usability, above all

    View full-size slide

  87. @dokun24
    @mccoyjus
    The Jupyter Project

    View full-size slide

  88. @dokun24
    @mccoyjus
    The Jupyter Project
    • Notebook driven development

    View full-size slide

  89. @dokun24
    @mccoyjus
    The Jupyter Project
    • Notebook driven development
    • Easy to share experiments &
    documentation

    View full-size slide

  90. @dokun24
    @mccoyjus
    The Jupyter Project
    • Notebook driven development
    • Easy to share experiments &
    documentation
    • Portable, web-based
    environment

    View full-size slide

  91. @dokun24
    @mccoyjus
    Watson Studio

    View full-size slide

  92. @dokun24
    @mccoyjus
    Watson Studio
    • Data science and IBM Cloud

    View full-size slide

  93. @dokun24
    @mccoyjus
    Watson Studio
    • Data science and IBM Cloud
    • Democratizes the model
    training process

    View full-size slide

  94. @dokun24
    @mccoyjus
    Watson Studio
    • Data science and IBM Cloud
    • Democratizes the model
    training process
    • Built on open source

    View full-size slide

  95. @dokun24
    @mccoyjus
    Watson Studio
    • Data science and IBM Cloud
    • Democratizes the model
    training process
    • Built on open source
    • No native support for Swift…yet

    View full-size slide

  96. @dokun24
    @mccoyjus
    Swift - Forked

    View full-size slide

  97. @dokun24
    @mccoyjus
    Swift - Forked

    View full-size slide

  98. @dokun24
    @mccoyjus
    Swift - Forked

    View full-size slide

  99. @dokun24
    @mccoyjus
    Swift - Forked
    +

    View full-size slide

  100. @dokun24
    @mccoyjus
    Python
    Swift
    Swift
    Swift

    View full-size slide

  101. @dokun24
    @mccoyjus
    Swift
    Swift
    Swift
    Swift

    View full-size slide

  102. @dokun24
    @mccoyjus
    Demo

    View full-size slide

  103. @dokun24
    @mccoyjus

    View full-size slide

  104. @dokun24
    @mccoyjus

    View full-size slide

  105. @dokun24
    @mccoyjus
    Memory Benchmarking

    View full-size slide

  106. @dokun24
    @mccoyjus
    MB
    0
    175
    350
    525
    700
    Node.js Ruby Python Swift
    Memory Benchmarking

    View full-size slide

  107. @dokun24
    @mccoyjus
    MB
    0
    175
    350
    525
    700
    Node.js Ruby Python Swift
    658.324
    Memory Benchmarking

    View full-size slide

  108. @dokun24
    @mccoyjus
    MB
    0
    175
    350
    525
    700
    Node.js Ruby Python Swift
    511.724
    658.324
    Memory Benchmarking

    View full-size slide

  109. @dokun24
    @mccoyjus
    MB
    0
    175
    350
    525
    700
    Node.js Ruby Python Swift
    280.624
    511.724
    658.324
    Memory Benchmarking

    View full-size slide

  110. @dokun24
    @mccoyjus
    MB
    0
    175
    350
    525
    700
    Node.js Ruby Python Swift
    192.436
    280.624
    511.724
    658.324
    Memory Benchmarking

    View full-size slide

  111. @dokun24
    @mccoyjus
    Speed Benchmarking

    View full-size slide

  112. @dokun24
    @mccoyjus
    Seconds
    0
    25
    50
    75
    100
    Node.js Ruby Python Swift
    Speed Benchmarking

    View full-size slide

  113. @dokun24
    @mccoyjus
    Seconds
    0
    25
    50
    75
    100
    Node.js Ruby Python Swift
    45.41
    Speed Benchmarking

    View full-size slide

  114. @dokun24
    @mccoyjus
    Seconds
    0
    25
    50
    75
    100
    Node.js Ruby Python Swift
    50.97
    45.41
    Speed Benchmarking

    View full-size slide

  115. @dokun24
    @mccoyjus
    Seconds
    0
    25
    50
    75
    100
    Node.js Ruby Python Swift
    93.55
    50.97
    45.41
    Speed Benchmarking

    View full-size slide

  116. @dokun24
    @mccoyjus
    Seconds
    0
    25
    50
    75
    100
    Node.js Ruby Python Swift
    5.05
    93.55
    50.97
    45.41
    Speed Benchmarking

    View full-size slide

  117. @dokun24
    @mccoyjus

    View full-size slide

  118. @dokun24
    @mccoyjus
    Maybe We Should

    View full-size slide

  119. @dokun24
    @mccoyjus
    References
    • https://benchmarksgame-team.pages.debian.net/
    benchmarksgame/performance/binarytrees.html
    • https://console.bluemix.net
    • https://dataplatform.ibm.com
    • https://swift.org
    • https://ibm.biz/iswift4tensorflow

    View full-size slide

  120. @dokun24
    @mccoyjus
    Thank you!!!

    View full-size slide