35
Mobile, open source, and the drive to the cloud Karl Weinmeister Senior Manager, Swift@IBM Engineering

Swift at IBM: Mobile, open source and the drive to the cloud

Embed Size (px)

Citation preview

Page 1: Swift at IBM: Mobile, open source and the drive to the cloud

Mobile, open source, and the drive to the cloud

Karl WeinmeisterSenior Manager, Swift@IBM Engineering

Page 2: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 3: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 4: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 5: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 6: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 7: Swift at IBM: Mobile, open source and the drive to the cloud

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)

Page 8: Swift at IBM: Mobile, open source and the drive to the cloud

8

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

Page 9: Swift at IBM: Mobile, open source and the drive to the cloud

9

Growth in Swift Popularity2014 2015

Page 10: Swift at IBM: Mobile, open source and the drive to the cloud

10

Surging Popularity within 6 months compared to other popular languages

Page 11: Swift at IBM: Mobile, open source and the drive to the cloud

11

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

Page 12: Swift at IBM: Mobile, open source and the drive to the cloud

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 Package Catalog

Page 13: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 14: Swift at IBM: Mobile, open source and the drive to the cloud

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)

Page 15: Swift at IBM: Mobile, open source and the drive to the cloud

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)

Page 16: Swift at IBM: Mobile, open source and the drive to the cloud

16

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

Page 17: Swift at IBM: Mobile, open source and the drive to the cloud

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:

Page 18: Swift at IBM: Mobile, open source and the drive to the cloud

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):

Page 19: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 20: Swift at IBM: Mobile, open source and the drive to the cloud

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:

Page 21: Swift at IBM: Mobile, open source and the drive to the cloud

Mac OS X: swift buildLinux: 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

Page 22: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 23: Swift at IBM: Mobile, open source and the drive to the cloud

23

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

Page 24: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 25: Swift at IBM: Mobile, open source and the drive to the cloud

Application Events: OpenWhisk Resources

https://new-console.ng.bluemix.net/openwhisk

https://github.com/openwhisk

Page 26: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 27: Swift at IBM: Mobile, open source and the drive to the cloud

Application Integration: Swift Package Catalog

https://swiftpkgs.ng.bluemix.net/

Page 28: Swift at IBM: Mobile, open source and the drive to the cloud

28

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 ServicesProvision IBM Cloud Service Packages and Credentials

SwiftPackages

Swift on the server

DockerWhiskCloudFoundrySandbox

Developer Experience

Page 29: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 30: Swift at IBM: Mobile, open source and the drive to the cloud

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

Page 31: Swift at IBM: Mobile, open source and the drive to the cloud

Swift on the IBM Cloud

31

Page 32: Swift at IBM: Mobile, open source and the drive to the cloud

32

Swift@IBM - Developer Resources

https://developer.ibm.com/swift/

The Swift@IBM devCenter Join IBM Swift Engineering and leverage the latest resources

Page 33: Swift at IBM: Mobile, open source and the drive to the cloud

33

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

Page 34: Swift at IBM: Mobile, open source and the drive to the cloud

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…

Page 35: Swift at IBM: Mobile, open source and the drive to the cloud

35

Thank you, @kweinmeister