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

swift-for-backend-SNAPSHOT-2016-03

 swift-for-backend-SNAPSHOT-2016-03

The open-sourcing of Swift brought lots of love for non-OSX programmers. Linux support is a huge step for making Swift a full stack language, equally suited for server and client side applications. While it's very much a work in progress, there's already been built a vibrant landscape of backend-oriented frameworks and libraries, coming both from the community and the enterprises. Let's see what tools are available, how they can be used and why Swift on server side might be a good idea, despite the early stage.

Krzysztof Siejkowski

March 31, 2016
Tweet

More Decks by Krzysztof Siejkowski

Other Decks in Programming

Transcript

  1. swift-for-backend
    SNAPSHOT-2016-03
    .tar.gz
    by Krzysztof Siejkowski (siejkowski.net)

    View Slide

  2. swift ❤ linux

    View Slide

  3. View Slide

  4. server!
    framework!
    but which one?
    https://github.com/
    matteocrippa/awesome-
    swift#network

    View Slide

  5. Kitura
    github.com/IBM-Swift/Kitura
    Perfect
    perfect.org
    Vapor
    github.com/qutheory/vapor

    View Slide

  6. Zewo
    zewo.io
    Currasow
    github.com/kylef/Curassow
    Swifter
    github.com/httpswift/swifter

    View Slide

  7. Taylor
    github.com/izqui/Taylor
    Swifton
    github.com/necolt/Swifton
    Express
    swiftexpress.io
    Nest Project (Nest + Frank)
    github.com/nestproject

    View Slide

  8. blackfish
    github.com/elliottminns/blackfish
    Dynamo
    github.com/johnno1962/Dynamo
    Kunugi
    github.com/novi/Kunugi
    Trevi
    github.com/Trevi-Swift/Trevi

    View Slide

  9. Hello World! !

    View Slide

  10. Perfect perfect.org

    View Slide

  11. how to set up?
    1.Download Perfect
    2.Create Xcode workspace
    3.Add Perfect as subprojects
    4.Setup targets (see tutorial)
    5.Run!

    View Slide

  12. Hello world in Perfect demo
    code at github.com/siejkowski/SwiftForBackend/tree/master/Hello

    View Slide

  13. enterprise-ish and feature-rich...

    View Slide

  14. .. but not very swifty

    View Slide

  15. recap
    » yes we can!
    » many libraries
    » easy to try

    View Slide

  16. Slack bot! !

    View Slide

  17. Zewo
    zewo.io

    View Slide

  18. Set up
    1.Install swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a
    2.Install "Swift Command Line Application" template
    3.Create Xcode project with SPM folders and targets
    4.Install Zewo dependencies
    5.Install zewodev
    6.Checkout & generate Zewo using zewodev
    7.Add Zewo to my Xcode project
    8.RUN!

    View Slide

  19. View Slide

  20. !1. Install swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a
    Swift?
    Which Swift?
    https://swift.org/download/

    View Slide

  21. swift-2.2-RELEASE
    swift-2.2-SNAPSHOT-2016-03-01-a
    swift-2.2.1-SNAPSHOT-2016-03-28-a
    swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a
    swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a
    swift-DEVELOPMENT-SNAPSHOT-2016-02-25-a
    swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a

    View Slide

  22. swiftenv
    Swift Version Manager
    by Kyle Fuller
    $ swiftenv install swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a
    $ swiftenv global DEVELOPMENT-SNAPSHOT-2016-02-08-a

    View Slide

  23. !2. Install template
    !3. Create Xcode / SPM project
    Swift Package Manager (aka SPM)
    Package
    !"" Package.swift
    !""""""""""""""""""""""""""""""""""""""" Tests
    #"" Sources !"" LinuxMain.swift
    !"" Module1 !"" Module1
    $ #"" FileFromModule1.swift $ #"" TestForModule1.swift
    #"" Module2 #"" Module2
    #"" FileFromModule2.swift #"" TestForModule2.swift

    View Slide

  24. Package.swift
    import PackageDescription
    let package = Package(name: "Package",
    targets: [
    Target(name: "Package",
    dependencies: [ .Target(name: "Module1"),
    .Target(name: "Module2") ]),
    Target(name: "Module1"),
    Target(name: "Module2"),
    ],
    dependencies: [
    .Package(url: "https://github.com/SwiftyLib/Lib.git",
    majorVersion: 0)
    ]
    )

    View Slide

  25. !2. Install "Swift Command Line Application"
    template
    !3. Create Xcode project with SPM folders and
    targets
    Xcode ! SPM

    View Slide

  26. !5. Install zewodev
    !6. Checkout & generate Zewo using zewodev
    !7. Add Zewo to my Xcode project
    Make Xcode ❤ SPM
    $ sudo gem install zewo-dev

    View Slide

  27. !4. Install Zewo dependencies
    SPM wants to ❤ C libraries
    and external dependencies
    $ brew install zewo/tap/zewo

    View Slide

  28. !8. RUN!

    View Slide

  29. Slack bot in Zewo demo
    code at github.com/siejkowski/SwiftForBackend/tree/master/Hackathon

    View Slide

  30. very modular

    View Slide

  31. much swifty

    View Slide

  32. How to deploy it?
    docker
    heroku

    View Slide

  33. recap
    » swiftenv
    » SPM & modularity
    » Xcode / SPM
    » SPM / C libs
    » Docker, Heroku

    View Slide

  34. App backend! !

    View Slide

  35. How many of you
    use Mac
    for Swift
    development?

    View Slide

  36. JetBrains
    CLion
    with Swift plugin

    View Slide

  37. Perfect: 6487
    Vapor: 3455 !
    Kitura: 2631 !
    Swifton: 1806 !
    Swifter: 1579 !

    View Slide

  38. github.com/qutheory/vapor

    View Slide

  39. github.com/IBM-Swift/Kitura

    View Slide

  40. View Slide

  41. what could
    possibly
    go wrong?

    View Slide

  42. ! package name conflict
    ! Swift version requirement

    View Slide

  43. ! Swift / SPM maturity
    ! Cross-project standards
    SwiftX

    View Slide

  44. Backend in Kitura & Vapor demo
    code at github.com/siejkowski/SwiftForBackend/tree/master/Prototype/Backend

    View Slide

  45. Full stack Swift !

    View Slide

  46. Things missing Opportunities !
    » utilities of all kind
    » ports from other platforms
    » architecture models (like actor model)
    » monitoring tools
    » SwiftJS (ShiftJS)
    » performance
    » many more

    View Slide

  47. recap
    » development on Linux
    » mix and match !
    » full stack
    » opportunities!

    View Slide

  48. View Slide

  49. Conwey's law
    “organizations which design systems (in the broad
    sense used here) are constrained to produce designs
    which are copies of the communication structures of
    these organizations”
    Melvin E. Conway, April, 1968

    View Slide

  50. backend
    for
    frontend
    diagram and further info at
    samnewman.io/patterns/
    architectural/bff/

    View Slide

  51. SNAPSHOT-2016-03
    obsolete tomorrow!
    contact the community!

    View Slide

  52. Thank you!
    Questions?

    View Slide