Der Mauersegler

Major components of Mac OS X, including the UNIX core, are made available under Apple’s Open Source license, allowing developers and students to view source code,

learn from it and submit suggestions and modifications.

NSString *str = @"hello,";
str = [str stringByAppendingString:@" world"];
var str = "hello,"
str += " world"

Objective-C

Swift

Syntax Highlights

Typing

let double = 70.0
let typedDouble: Double = 70.0

var array = [1, 2, 3]
var typedArray: [String] = ["a", "b"]


// Type checking:
if m is Movie {
  //...
}

First Class Functions

  • can be nested, assigned and used as return value
  • Closures
  • multiple return values

Classes

class Vehicle {
    var numberOfWheels = 0
    var description: String {
        return "\(numberOfWheels) wheel(s)"
    }

    func init() {
        //...
    }

    func deinit() {
        //...
    }
}

Optionals

func printName(optionalName: String?) {
    if let name = optionalName {
        print("Hello, \(name)")
    } else {
        print("Hello!")
    }   
}

printName("John Appleseed")
printName(nil)

Editors

https://swiftlang.ng.bluemix.net/

  • JetBrains AppCode
  • Sublime/Atom Plugins
  • But in reality...

IDEs

UPs

  • 1 language --> many (Apple) platforms
  • Type Inference
  • Omit self keyword in most cases
  • Batteries Included (eg. Test framework)
  • @testable
  • Core Data / Interface Builder

DOWNs

  • Objective-C still present
  • Steep learning curve
  • XCode & XCode Server
  • Swift not really relevant outside Apple cosmos

Der Mauersegler

By Michael Müller

Der Mauersegler

Presentation about the Swift programming language

  • 328