Upload
devevents
View
144
Download
0
Embed Size (px)
Citation preview
OSCON 2016 – Swift
Mobile, open source, and the drive to the cloud
Patrick BohrerIBM Cloud@pbohrer
OSCON 2016 – Swift 2
Agenda• Why:
• Enabling Modern App Design Patterns• What:
• Logic, Data, Events & Integration powered by Open Source• How:
• Developer Experience & Tools• Get Involved:
• Sample End-to-end Applications• Resources & Links
OSCON 2016 – Swift 3
Modern Application Design: TiersApplication-specific
BackendOther Cloud Services
On-prem Services
Experiences being built by this community are dramatically
changing the way we live and work
New Experiences
User-facing Client Apps
Things / Sensors
End Users
OSCON 2016 – Swift 4
Modern Application Design: Tier AttributesApplication-specific
BackendOther Cloud Services
On-prem Services
End UsersUser-facing Client Apps
Role: User Interactions & Remote
Sensing
Application State: User & View Specific
State, Caching of eventually consistent
state
Usage: Sometimes on, Driven by Users
and Events
Resources: Constrained CPU, Mem, Network BW
Role: IntegrationService Composition,
Background Monitoring/Activity,
Event/Traffic Routing, State synchronization
across clients and things
Application State: Global Application State
Usage: Always-on, Always Connected
Resources: Unlimited CPU, Mem, Network BW
OSCON 2016 – Swift 5
Modern Application Design: Tier AttributesApplication-specific
BackendOther Cloud Services
On-prem Services
End UsersUser-facing Client Apps
Developer Experience• Tight Coupling/Dependency between Client
Apps and Application Backend• Need ability to deploy the right functionality
to the proper tier to deliver world class experience
• Successful experience reached through fast iterations
OSCON 2016 – Swift 6
Modern Application Design: Application ConstructsApplication-specific
BackendOther Cloud Services
On-prem ServicesLogic: Client and Server-side Swift
Data: Cloudant, MongoDB, Redis, ElasticSearch, PostgresQL, etc
Events: OpenWhisk
Integration: Open Github Packages
User-facing Client Apps
Developer Experience
End Users
OSCON 2016 – Swift
Application Logic: Swift (Client and Server)• Swift Background• What is included in Swift.org ?• Trends• Bringing Swift to the Server
• Core contributions• Motivating Server Projects (Kitura & more)
OSCON 2016 – Swift
Swift.org: What is included?• Open Sourced Dec 3, 2015• Swift Language• Core libraries:
• XCTest• Libdispatch (GCD)• Foundation for non-Apple hosts (New)
• LLVM Compiler & Debugger (swift-lldb, swift-llvm, swift-clang)• Swift Package Manager (New)
OSCON 2016 – Swift 9
IBM Swift Sandbox
The IBM Swift SandboxExperiment with Swift on the server, share your code and collaborate with your peers
http://swiftlang.ng.bluemix.net
Features• One click access to Swift
on Linux (multiple versions)
• Mobile UI & Auto Saving Draft
• Code Snapshots & Sharing, UI Themes, Social
• Social Sharing
OSCON 2016 – Swift 10
Growth in Swift Popularity2014 2015
OSCON 2016 – Swift 11
Surging Popularity within 6 months compared to other popular language
OSCON 2016 – Swift 12
New Client-side Development Community
Hybrid / Web App Development
NodeJS Attracted Web-based Developers to the Cloud
Swift App Development
Swift on the Server can attract Swift-based Developers
>11 Million Apple
Developers
~100 Apple/IBM Enterprise Solutions and Assets
OSCON 2016 – Swift
Lessons to be learned from NodeJS TimelineV8 Release
(2008)
+ libuv (concurency)+ foundation = NodeJS(2009)
+ npm(2009-2011)
Initial Popularity(2012-2013)
Mainstream Usage(2014-2015)
Swift Release(Late 2015)
+ libdispatch (concurrency)+ Foundation+ Web Foundation (Kitura) = ??(2016)
+ swift pkg mgr+ catalog(? 2016)
Package Growth(2012)
Package Growth(2016-2017)
Mainstream Usage(??)
+ Express: beta1.0(Web Framework)(2009-2010)
+ Kitura: alpha1.0(Web Framework)(2016-?)
Initial Popularity(??)
Swift.org Contributions
Sandbox
OSCON 2016 – Swift
Swift.org Contributions
Mailing lists (https://swift.org/community/#mailing-lists)Very active communityIBM’s involvement in bringing Swift to the Cloud• Core Libraries
• Foundation• Libdispatch
• Motivating Server Projects• Kitura Web Framework• Web Foundation Libraries• OpenWhisk support of Swift
OSCON 2016 – Swift 15
Status Quo
Still early days• Language evolution (1.0 2.0 3.0 4.0) currently at 2.2 3.0
New (Very early):• Swift Package Manager:
• One of the key developers is Max Howell (creator of Homebrew on Mac)
New on Linux (Still in progress)• Libdispatch (Concurrency)• Foundation (New for non-Apple platforms)
OSCON 2016 – Swift
Apple Client Deployment Server/Cloud Deployment
Application-Specific Cloud ServicesClient Facing App
Beyond Swift.org: Bringing Swift to the Server• Drive towards consistent Swift developer experience across Client & Server• Building / Investing in Core Swift Libraries (Foundation & Libdispatch)• Motivated/Prioritized through open source projects (Kitura & OpenWhisk)• Deployment options across open source technology (Docker, Cloud Foundry, Vagrant)
Foundation
Swift
Swift Standard Library
Core Foundation
Dis
patc
hP
WQ C
libs
GLi
bc
Foundation
Swift
Swift Standard Library
Core Foundation
Dis
patc
h
Dar
win
C li
bs
Client-specific Libraries App Libraries Server-specific LibrariesApp Libraries
Driving Towards Consistent Runtime across Clients/Servers
OpenWhisk & Kitura-based Server-side Environments (Built with Foundation & Libdispatch)
OSCON 2016 – Swift 17
Kitura Web FrameworkWhat is it?New, modular, package-based web framework written in Swift
Why is this cool?Empower a new generation of native mobile developers to write and deploy code into the Cloud.
Developer Benefits ?Delivers core technologies needed to stand up enterprise apps on the server
Enables developers to create a web application in Swift and deploy these servers on Linux and the Cloud.
http://github.com/ibm-swift/kitura
OSCON 2016 – Swift
myFirstProject├── Package.swift├── Sources│ └── main.swift└── Tests └── empty
mkdir myFirstProject
2. Next initialize this project as a new Swift package project
Develop a Kitura Web Application in Swift
1. First we create a new project directory
cd myFirstProjectswift build --init
Now your directory structure under myFirstProject should look like this:
OSCON 2016 – Swift
import Kitura import KituraNet import KituraSysimport SwiftyJSON
import PackageDescription
let package = Package( name: "myFirstProject", dependencies: [
.Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 0, minor: 13) ])
4. Import the modules in your code (Sources/main.swift):
Develop a Kitura Web Application in Swift
3. Now we add Kitura as a dependency for your project (Package.swift):
OSCON 2016 – Swift
let server = HTTPServer.listen(port: 8090, delegate: router) Server.run()
let router = Router()
router.get("/hello") { request, response, next in response.status(.OK).send("<h1>Hello, World!</h1>") next()
}
7. Create and start a HTTPServer:
Develop a Kitura Web Application in Swift
5. Add a router and a path:
router.get("/hello.json") { request, response, next in response.status(.OK).send(json: JSON(["Hello": "World!"])) next()
}
6. Add a JSON data route
OSCON 2016 – Swift
import Kitura import KituraNet import KituraSys import SwiftyJSON
let router = Router()
router.get("/hello") { request, response, next in response.status(.OK).send("<h1>Hello, World!</h1>") next()
}
router.get("/hello.json") { request, response, next in response.status(.OK).send(json: JSON(["Hello": "World!"])) next()
}
let server = HTTPServer.listen(port: 8090, delegate: router) Server.run()
Develop a Kitura Web Application in Swift
8. Sources/main.swift file should now look like this:
OSCON 2016 – Swift
Linux: swift build -Xcc –fblocksMac OS X: swift build -Xcc -fblocks -Xswiftc -I/usr/local/include -Xlinker -L/usr/local/lib
Develop a Kitura Web Application in Swift
9. Compile your application:
.build/debug/myFirstProject
10. Run your web application:
11. Open your browser:http://localhost:8090/hellohttp://localhost:8090/ http://localhost:8090/hello.json
OSCON 2016 – Swift
Application Data: Open Technology
Today, developers chose their cloud data technology based on the demands of their application. IBM is happy to offer a wide range of open technologies in managed offerings: Cloudant, Redis, MongoDB, Postgres, ElasticSearch, RethinkDB, and more
OSCON 2016 – Swift 24
Package (P)
Action f(x)
Trigger (T)
Rule (R)
R = T f(x)
Namespace
f(x)
Application Events: OpenWhisk OverviewHigh-level
ArchitectureTriggers: A class of events emitted by event sources.
Actions: Encapsulate the actual code to be executed which support multiple language bindings. Actions invoke any part of an open ecosystem.
Rules: An association between a trigger and an action.
Packages: Describe external services in a uniform manner.
Combined these allow developers to compose solutions using modern abstraction and chaining which can be created, accessed, updated and deleted via the CLI
OSCON 2016 – Swift
OpenWhisk: How does it work?
OpenWhisk
Swift Docker …
Incoming HTTP requestBrowser
Mobile App
Web App
Variety of languages
Event Providers
Cloudant
Git
Weather
…
…
Trigger execution of associated OpenWhisk
action
JS
OSCON 2016 – Swift
Application Events: OpenWhisk Resources
https://new-console.ng.bluemix.net/openwhisk
https://github.com/openwhisk
OSCON 2016 – Swift
Application Integration: Swift Packages• Swift.org introduced the Swift Package Manager• Lack of standardization on packages creates a bit of package hell • Welcome addition but still early days• Growing content seen in Github• Catalog to help with sharing and discovery• Client and Server side packages
• Building upon lessons learned in other package managers
OSCON 2016 – Swift
Application Integration: Swift Package Catalog
https://swiftpkgs.ng.bluemix.net/
OSCON 2016 – Swift 29
Xcode DeveloperExperience
Swift on the client
Build and Debug Applications
IBM Swift SandboxCollaborative Code as Questions/Answers
Provision 3rd Party Client-side Registered Swift Packages
IBM Cloud Tool (prototype)Provision IBM Cloud Service Packages and Credentials
SwiftPackages
Swift on the server
DockerWhiskCloudFoundrySandbox
Developer Experience
OSCON 2016 – Swift
Sample Applications: BluePic
BluePic is a photo sharing app that allows you to take photos, upload them and share them with a community. The BluePic community will be made up of all the users that run an instance of your created app.
https://github.com/IBM-Swift/Kitura-BluePic
OSCON 2016 – Swift
Sample Applications: TodoList
A shared example to showcase backend tech stackshttp://todobackend.com/
An example using Kitura to develop a Todo-Backendhttps://github.com/IBM-Swift/Kitura-TodoList
OSCON 2016 – Swift
Swift on the IBM Cloud
32
OSCON 2016 – Swift 33
Swift@IBM - Developer Resources
https://developer.ibm.com/swift/
The Swift@IBM devCenter Join IBM Swift Engineering and leverage the latest resources
OSCON 2016 – Swift 34
Technical Blog Threads on Swift@IBMSwift (General)
• Why I’m Excited about Swift (12/3)
• Running Swift within Docker (12/15)
• Introducing the (beta) IBM Watson iOS SDK! (12/18)
Swift Sandbox
• Introducing Swift Sandbox (12/3)
• Hello Swift! IBM Swift Sandbox Day 1 Wrapup (12/5)
• #HourofCode: Learn Swift in three easy steps today! (12/8)
• Introduction to Swift Tutorial using the IBM Swift Sandbox (12/8)
• What’s new in the IBM Swift Sandbox v0.3 (12/21)
• Exploring Swift on Linux (12/28)
• What’s new in the IBM Swift Sandbox v0.4 (1/20)
https://developer.ibm.com/swift/blogs
Swift (General)
• Swift on POWER Linux (2/1)
• Seven Swift Snares & How to Avoid Them (1/27)
Interconnect 2016
• Build End-to-End Cloud Apps using Swift with Kitura (2/21)
• Introducing the Swift Package Catalog (2/21)
• Talking about Swift Concurrency on Linux (2/21)
• Explore the IBM Swift Sandbox 1-2-3 (2/21)
• Using the Cloud Foundry Buildpack for Swift on Bluemix (2/21)
• 10 Steps To Running a Swift App in an IBM Container (2/21)
• Build End-to-End Cloud Apps using Swift with Kitura (2/21)
Drumbeat of Blogs/Announcements from IBM Swift Engineering Community
OSCON 2016 – Swift
Summary
Deployment Options
Swift.org Projects Community Packages
Server Projects
Foundation, libdispatch, clang, llvm, swift-package-manager
MongoDB, Redis, CouchDB, Postgresql, Elasticsearch, MQ
Open Source OverviewDeveloper Resources
Swift Sandbox
Package CatalogAnd many more…
OSCON 2016 – Swift 36
Innovators &
Early Adopters Wanted
Get involved now at swift.org
&developer.ibm.com/swift
Thank you,@pbohrer
OSCON 2016 – Swift 37
Thank you, @pbohrer