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

Mobile Backends mit Swift

swenden
September 15, 2016

Mobile Backends mit Swift

In diesen Talk untersuchen wir ob die junge und von Apple entwickelte Programmiersprache Swift sich für die Entwicklung von Mobile Backends eignet.

swenden

September 15, 2016
Tweet

More Decks by swenden

Other Decks in Programming

Transcript

  1. Frontend–Backend In software engineering, front end and back end distinguish

    between the separation of concerns between the presentation layer (the front end) - which is the interface between the user - and the data access layer (the back end). The front and back ends may be distributed among one or more systems. — en.wikipedia.org
  2. MBaaS Mobile backend as a service (MBaaS),…, is a model

    for providing web app and mobile app developers with a way to link their applications to backend cloud storage and APIs exposed by back end applications while also providing features such as user management, push notifications, and integration with social networking services. — en.wikipedia.org
  3. Eigenschaften → OOP, FP, POP → kompiliert → statisch, stark

    getypt → Block-Struktur → Designed for Safety
  4. Historie → Juni 2014: Vorstellung von Swift → September 2014:

    – Version 1.0 → September 2015: Version 2.0 → Dezember 2015: Open Source Release → 14. September 2016: Version 3.0
  5. Optionals var person: String? if person == nil { print("person

    is nil") } person = "Peter" if let unwrappedPerson = person { print("The name is: \(unwrappedPerson)") }
  6. Class, Struct, Enum & Protocol class BedCon { var year:

    Int init(year: Int) { self.year = year } } let bedcon = Bedcon(year: 2016)
  7. Funktionen func calculateHard(number: Int, anotherNumber: Int) -> Int { return

    1000 * number } calculateHard(number: 10, anotherNumber: 100)
  8. Extensions typealias Meter = Double extension Double { var km:

    Double { return self / 1_000.0 } } let twoThousandMeter = Meter(2000) let twoThousandMeterInKm = twoThousandMeter.km
  9. Guards func fibonacci(number: Int) -> Int { guard number >

    1 else { return number } return (fibonacci(number: number - 1) + fibonacci(number: number - 2)) } let number = fibonacci(number: 10)
  10. Closures let numbers = ["321", "21", "1"] var sortedByLength =

    numbers.sorted(by: { (s1: String, s2: String) -> Bool in return s1.characters.count < s2.characters.count }) sortedByLength = numbers.sorted() { $0.characters.count < $1.characters.count }
  11. Swift in der Zukunft → 2017 Veröffentlichung von Version 4

    → Diskussionen bei Facebook & Google → Einsatz im Umfeld des Maschinellen Lernens?
  12. Perfect It provides everything a Swift engineer needs for developing

    lightweight, maintainable, and scalable apps and other REST services entirely in the Swift programming language for both client-facing and server-side applications. — perfect.org
  13. Perfect let server = HTTPServer() var routes = Routes() routes.add(method:

    .get, uri: "/path/one", handler: { request, response in response.setBody(string: "Handler was called") response.completed() }) server.addRoutes(routes) server.serverPort = 8181 server.documentRoot = "./webroot" do { try server.start() } catch PerfectError.networkError(let err, let msg) { print("Network error thrown: \(err) \(msg)") }
  14. Kitura Kitura is a web framework and web server that

    is created for web services written in Swift. — https://github.com/IBM-Swift/Kitura
  15. Kitura import Kitura let router = Router() router.get("/") { request,

    response, next in response.send("Hello, World!") next() } router.all("/my/path", middleware: StaticFileServer(path: "./files")) Kitura.addHTTPServer(onPort: 8090, with: router) Kitura.run()
  16. Vapor Vapor is the most used web framework for Swift.

    It provides a beautifully expressive and easy to use foundation for your next website or API. — https://github.com/vapor/vapor
  17. Vapor import Vapor let drop = Droplet() drop.get("version") { request

    in return try Json(["version": "1.0"]) } drop.start()
  18. Deployment & Hosting → Lediglich ein Linux notwendig → Heroku

    & IBM Support → Docker – swiftlang/swift
  19. !

  20. Q&A