A Language of Ideas: Swift

About Dimitri

Swift

What is Swift?

  • A general-purpose programming language 
  • A multi-paradigm programming language 
  • A multiplatform programming language 

Multiplatform you say?

  • iOS
  • macOS
  • watchOS
  • tvOS
  • Linux

What else is Swift?

  • Works with Apple's Cocoa and Objective-C code
  • Cross platform
  • Cross device
  • With full stack potential

History

  • Development of Swift started in July 2010
  • Swift reached the 1.0 milestone on September 9, 2014
  • Came out of the gate swinging
  • A year later, it was made open-source
  • In secret
  • First apps appeared online shortly thereafter
  • Is on an annual release schedule

Ideas

  • Protocol oriented programming
  • Optionals ensure that nil values are handled explicitly.
  • Memory is managed automatically.
  • Error handling allows controlled recovery from unexpected failures.
  • An enumeration is a data type consisting of a set of named values, called members

Hello World

print("Hello World")

Swift Playgrounds

Why a new language?

  • Adapting to tectonic changes
  • Easier to read and maintain than Objective-C
  • Safety, performance and memory management
  • Reduced learning curve
  • Easier to read and maintain than Objective-C
  • New infrastructure ~ The cloud
  • New devices

Swift is bad because...

  • Still evolving and breaking
  • It is beholden to a single company
  • ish
  • It's a new language
  • Needs to mature for the dark areas to light up
  • Lack of tools
  • But more being created and released
  • Not many developers yet
  • But has a rapidly growing community
  • for now

About Thanos

  • ~10 years on iOS
  • 🤮 Objective-C
  • ❤️ Swift
  • Currently iOS engineer at waldophotos.com

Web Development

Frameworks

Around since 2016

Developed by IBM

Blessed by Apple - Apple WWDC 2016

Has a stamp of approval feeling for Swift

Since 2016 as an open-source software

Developed by Tanner Nelson and Logan Wright

Is worked on full time

13K stars on github

Created by PerfectlySoft

Released on 23 November 2015

Claimed by the authors as production ready

Features

  • Authentication
  • Data formats
  • Templating
  • Databases

Authentication

  • Google, LinkedIn or Facebook authentication
  • Granting access with OAuth2
  • Perfect, and Kitura support GitHub account athentication
  • Perfect supports Slack

Data formats

  • All frameworks support JSON as the default data format
  • Kitura supports - MQTT is a machine-to-machine/IoT connectivity protocol.
  • All frameworks support XML
  • Perfect shines here though; has a native cURL wrapper and support for direct operations on files, directories, and .zip files

Templates

  • Vapor uses a templating system called Leaf
  • Works with Vapor's underlying request and response mechanism
<!DOCTYPE html>
<html>
  <head>
    <title>Leaf View</title>
  </head>
  <body>
    <h1> You name #(name)! </h1>
  </body>
</html>

view.leaf

get("name") { req in 
    return try self.view.make("view", ["name": "Qui Gon Jinn"])
}

in your routing setup

Databases

  • SQL databases
  • MySQL, PostgreSQL, and SQLite
  • Perfect and Kitura also support CouchDB
  • Perfect and Vapor also have support MongoDB

Community

  • Vapor is a clear winner
  • On github
  • On stack overflow
  • Very eager on Slack

Deployment

All frameworks support Heroku, Amazon Web Services and Docker.

Deployment

Vapor has its own solution Vapor Cloud

Performance

Productivity

  • Swift developers can own a whole project end-to-end
  • In a single xcode project
  • On both client and server

Questions?

Made with Slides.com