Swift Summit: Pushing the boundaries of Swift to the Server
-
Upload
chris-bailey -
Category
Software
-
view
1.303 -
download
0
Transcript of Swift Summit: Pushing the boundaries of Swift to the Server
![Page 1: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/1.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Swift @ IBM Engineering TeamChris Bailey(@Chris__Bailey)
November 7th, 2016
Pushing Swift to the Server
![Page 2: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/2.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Why Swift on the Server?
![Page 3: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/3.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Performant Applications
4.0 4.315.8
134.2
0.0
20.0
40.0
60.0
80.0
100.0
120.0
Dur
atio
n (s
) (lo
wer
is b
ette
r)
http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=spectralnorm
![Page 4: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/4.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
15.0
32.2
25.3
54.6
0.0
10.0
20.0
30.0
40.0
50.0
60.0
Low MemoryM
emor
y U
sage
(MB)
(lo
wer
is b
ette
r)
http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=spectralnorm
![Page 5: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/5.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Swift is ideal for Cloud
![Page 6: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/6.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit@Chris__Bailey | Swift@IBM #swiftsummit
![Page 7: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/7.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
MARS
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 8: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/8.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
1998 Mars Climate ORbiteR
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 9: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/9.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
DeC 11: Launch from Cape Canaveral1998 Mars Climate ORbiteR
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 10: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/10.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
1998 Mars Climate ORbiteR DeC 11: Launch from Cape Canaveral
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 11: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/11.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
1999 Mars Climate ORbiteR Sept 23rd: Lost Radio Contact
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 12: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/12.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
1999 Mars Climate ORbiteR Sept 25th: Mission Declared a LOSS
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 13: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/13.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 14: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/14.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
PLANNED TRAJECTORY
![Page 15: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/15.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
PLANNED TRAJECTORY
TCM-4
![Page 16: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/16.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
PLANNED TRAJECTORY
TCM-4
![Page 17: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/17.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
PLANNED TRAJECTORY
TCM-4
226 KM
![Page 18: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/18.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
PLANNED TRAJECTORY
TCM-4
ACTUAL TRAJECTORY
226 KM
![Page 19: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/19.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
PLANNED TRAJECTORY
TCM-4
ACTUAL TRAJECTORY
226 KM
TCM-4
![Page 20: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/20.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
PLANNED TRAJECTORY
TCM-4
TCM-4 ACTUAL TRAJECTORY
226 KM
![Page 21: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/21.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
PLANNED TRAJECTORY
TCM-4
ACTUAL TRAJECTORY
226 KM
57 KM
TCM-4
![Page 22: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/22.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit@Chris__Bailey | Swift@IBM #swiftsummit
![Page 23: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/23.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Lockheed MartinGround SoftwareNasa Jet Propulsion Laboratory
Trajectory Calculation Software
![Page 24: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/24.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Lockheed MartinGround Software
Nasa Jet Propulsion Laboratory Trajectory Calculation Software
SIS(Software Interface Specification)
Total Impulse
pounds-seconds (United States Customary Unit)
newton-seconds (International System of Units)
14.45
![Page 25: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/25.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
“Software interop is hard”
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 26: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/26.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
“Software interop is hard” —Rocket Scientists
@Chris__Bailey | Swift@IBM #swiftsummit
![Page 27: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/27.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Siloed Development
APISpecification
Collaborate on API
Collaborate on API
Create
Deploy
Create
Deploy
![Page 28: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/28.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Collaborate on Project
Collaborate on Project
Collaborative Development
Deploy DeployGenerate
APISpecification
![Page 29: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/29.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Swift DevelopmentCollaborate on Swift Project
Deploy DeployGenerate
Swagger APISpecification
Collaborate on Swift Project
![Page 30: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/30.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Collaboratively Building Applications
![Page 31: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/31.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
December 3rd, 2015
Apache 2.0 Software Licence
Swift Everywhere
![Page 32: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/32.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Kitura: A Swift Web Framework and HTTP Server
http://kitura.io
![Page 33: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/33.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Server / Cloud Deployment Server / Cloud Deployment Apple Client Deployment
Client Facing App Client-Specific
Libraries
Kitura Web Framework
Swift
StandardLibrary Foundation Dispatch
Swift
StandardLibrary Foundation Dispatch
Net
wor
king
Sec
urity
HTT
P P
arsi
ng
Application Libraries
Application Specific Cloud Services
Server-Specific LibrariesApplication Libraries
Consistent Runtime across Clients/Servers
Kitura-based Server !Built with Dispatch & Foundation
Swift
“Server” APIs
Application Libraries
![Page 34: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/34.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Swift on the Server is Real
Swift 3.0 + Kitura 1.0
![Page 35: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/35.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Let’s take a tour…
![Page 36: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/36.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Create an ApplicationFirst, create a new project directory:$ mkdir myFirstProject
Next, create a new Swift project using the Swift Package Manager.$ cd myFirstProject$ swift package init —-type executable
In Package.swift, add Kitura as a dependency for your project.import PackageDescription
let package = Package( name: "myFirstProject", dependencies: [ .Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 0) ])
![Page 37: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/37.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Create an ApplicationIn Sources/main.swift, add the following code.import Kitura
// Create a new router let router = Router()
// Handle HTTP GET requests to / router.get("/") { request, response, next in response.send("Hello, World!") next() }
// Add an HTTP server and connect it to the router Kitura.addHTTPServer(onPort: 8090, with: router)
// Start the Kitura runloop (this call never returns) Kitura.run()
![Page 38: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/38.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Deploy an Application
Open your browser at http://localhost:8090
Compile and run your application:$ swift build$ .build/debug/myFirstProject
![Page 39: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/39.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Demo
![Page 40: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/40.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Use Services
![Page 41: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/41.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Deploy to Cloud
$ docker pull ibmcom/kitura-ubuntu:latest $ git clone https://github.com/IBM-Swift/Kitura-Starter-Bluemix
![Page 42: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/42.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Using Cloud Tools
http://cloudtools.bluemix.net
• Deployment made easy
• Clone, code, push
• Demo projects to try
![Page 43: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/43.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
http://www.kitura.io/en/resources/tutorials.html
Tutorials• Creating a Todo-List Backend• Adding Authentication with Kitura-Credentials• Adding Sessions with Kitura-Session• Using Templating Engines with Kitura• Enabling SSL/TLS on Kitura• Using FastCGI with Kitura• Special Types of Response Handlers• Parsing Requests
![Page 44: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/44.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Examples
Blitter Social Networkhttps://github.com/ibm-swift/blitter
BluePic Applicationhttps://github.com/ibm-swift/bluepic
![Page 45: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/45.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Discover Try
Build
IBM Cloud Tools
Package Catalog Swift Sandbox
Kitura + Packages
DeploySwift @ IBMhttps://developer.ibm.com/swift/
![Page 46: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/46.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Swift
![Page 47: Swift Summit: Pushing the boundaries of Swift to the Server](https://reader033.fdocuments.net/reader033/viewer/2022050614/587123801a28abe4448b59a3/html5/thumbnails/47.jpg)
@Chris__Bailey | Swift@IBM #swiftsummit
Swift For safer missions to Mars
@Chris__Bailey | Swift@IBM #swiftsummit