Karl Weinmeister presented on enabling modern application design patterns using open source technologies like Swift, Kitura, and OpenWhisk. He discussed how applications can be broken into user-facing client apps and backend services, and how Swift supports developing both tiers. He provided an overview of Kitura as a web framework for Swift on servers, demonstrated a simple Kitura app, and highlighted sample apps like BluePic. Weinmeister also discussed using OpenWhisk for application events and integration via Swift packages.
3. Modern Application Design: Tiers
3
Application-specific
Backend
Other 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
4. Modern Application Design: Tier Attributes
4
Application-specific
Backend
Other Cloud Services
On-prem Services
End Users
User-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: Integration
Service 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
5. Modern Application Design: Tier Attributes
5
Application-specific
Backend
Other Cloud Services
On-prem Services
End Users
User-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
6. Modern Application Design: Application Constructs
6
Application-specific
Backend
Other Cloud Services
On-prem Services
Logic: 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
7. 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)
8. IBM Swift Sandbox
The IBM Swift Sandbox
Experiment with Swift on the server,
share your code and collaborate with
your peers
http://swiftlang.ng.bluemix.net 8
Features
• One click access to Swift on
Linux (multiple versions)
• Mobile UI & Auto Saving
Draft
• Code Snapshots & Sharing,
UI Themes, Social
• Social Sharing
11. New Client-side Development Community
11
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
12. Lessons to be learned from NodeJS Timeline
V8 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 Package Catalog
13. Swift.org Contributions
Mailing lists (https://swift.org/community/#mailing-lists)
Very active community
IBM’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
14. 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)
14
15. 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
DispatchPWQ
Clibs
GLibc
Foundation
Swift
Swift Standard Library
Core Foundation
Dispatch
Darwin
Clibs
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)
16. Kitura Web Framework
What 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 16
17. 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 myFirstProject
swift build --init
Now your directory structure under myFirstProject should look like this:
18. import Kitura
import 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):
19. Kitura.addHTTPServer(port: 8090, with: router)
Kitura.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
20. import Kitura
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()
}
Kitura.addHTTPServer(port: 8090, with: router)
Kitura.run()
Develop a Kitura Web Application in Swift
8. Sources/main.swift file should now look like this:
21. Mac OS X: swift build
Linux: swift build -Xcc –fblocks
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
22. 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
23. 23
Package (P)
Action f(x)
Trigger (T)
Rule (R)
R = T f(x)
Namespace
f(x)
Application Events: OpenWhisk Overview
High-level
Architecture
Triggers: 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
24. OpenWhisk: How does it work?
OpenWhisk
Swift Docker …
Incoming HTTP request
Browser
Mobile App
Web App
Variety of
languages
Event Providers
Cloudant
Git
Weather
…
…
Trigger execution of
associated OpenWhisk
action
JS
26. 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
28. Xcode Developer
Experience
Swift on the client
Build and
Debug
Applications
IBM Swift Sandbox
Collaborative
Code as
Questions/An
swers
Provision 3rd Party Client-
side Registered Swift
Packages
IBM Cloud Services
Provision IBM Cloud
Service Packages and
Credentials
Swift
Packages
Swift on the server
Docker
Whisk
CloudFoundry
Sandbox
Developer Experience
28
29. 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
30. Sample Applications: TodoList
A shared example to showcase backend tech stacks
http://todobackend.com/
An example using Kitura to develop a Todo-Backend
https://github.com/IBM-Swift/Kitura-TodoList
32. Swift@IBM - Developer Resources
https://developer.ibm.com/swift/
The Swift@IBM devCenter
Join IBM Swift Engineering and
leverage the latest resources
32
33. Technical Blog Threads on Swift@IBM
Swift (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
33
34. 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 Catalog
And many more…
What is it ?
Kitura is a new, modular, package-based web framework written in the Swift language for use in standing up a web server written in Swift on both OSX and Linux.
Why is this cool ?
Now that Swift is open source, a number of included projects are coming together (swift, swift package manager, libdispatch, swift foundation) that makes the development of a Swift-based web server stack both inevitable as well as incredibly valuable means to empower a new generation of native mobile developers to write and deploy code into the Cloud as well.
Developer Benefits ?
Once you have a new language that runs on a server, many developers want to be able to quickly and easily create a web server written in that language. The swift language and runtime does not include a web framework that can be used to easily create a web server. IBM has created this project to enable developers to create a web application in Swift and deploy these servers on Linux and the Cloud.
IBM Message
We are leading the development of this web framework and will work with the community to evolve this framework over time as Swift on Linux evolves.
Other Details
-Discuss why we have multiple imports
Explain why all the additional C language dependencies
-Line up the font on Swift build
-
IBM Confidential
Simplified client/server programming model
Integrated Client/Server Swift Package Management and composition
IBM Cloud deployment and services provisioning
Client/Server Programming Model
IBM Sandbox collaborative coding and sharing