Swift Swiftly A quick introduction to the Swift language Oliver - - PowerPoint PPT Presentation

swift swiftly
SMART_READER_LITE
LIVE PREVIEW

Swift Swiftly A quick introduction to the Swift language Oliver - - PowerPoint PPT Presentation

Swift Swiftly A quick introduction to the Swift language Oliver Jones Technical Director Disclaimer Learning Swift iBooks The Swift Programming Language Using Swift with Cocoa and Objective-C Apple Developer Documentation


slide-1
SLIDE 1

Swift Swiftly

A quick introduction to the Swift language

Oliver Jones

Technical Director

slide-2
SLIDE 2

Disclaimer

slide-3
SLIDE 3

Learning Swift

  • iBooks
  • The Swift Programming Language
  • Using Swift with Cocoa and Objective-C
  • Apple Developer Documentation
  • WWDC 2014 Videos
  • Apple Developer Forums
  • Blogs, Github, Stack Overflow, etc
slide-4
SLIDE 4

What is Swift?

slide-5
SLIDE 5
  • A new programming language introduced at Apple’s

WWDC 2014 in June

  • Designed/Created by Chris Lattner
  • Apple Developer Tools department Director and

Architect

  • LLVM compiler project founder

What is Swift?

slide-6
SLIDE 6

What is Swift?

Objective-C without C

slide-7
SLIDE 7

Rusty Objective-C#++

What is Swift?

slide-8
SLIDE 8

Swift IS NOT Objective-C

(with new syntax)

What is Swift?

slide-9
SLIDE 9

Swift Code

slide-10
SLIDE 10
  • Native (x86 & ARM), Compiled
  • Strongly Typed
  • Designed for OS X and iOS developers
  • Intended to eventually replace Objective-C
  • Closed source (for now)

What is Swift?

slide-11
SLIDE 11

Notable Features

  • Bridges seamlessly to C & Objective-C (mostly)
slide-12
SLIDE 12
  • Type Inference & Explicitly mutable/immutable variables.

Notable Features

slide-13
SLIDE 13
  • Generics

Notable Features

slide-14
SLIDE 14
  • Operator Overloading

Notable Features

slide-15
SLIDE 15
  • Classes/Reference Types (objects) & Value Types (structs, enums)

Notable Features

slide-16
SLIDE 16
  • First Class Functions & Closures

Notable Features

slide-17
SLIDE 17
  • Tuples

Notable Features

slide-18
SLIDE 18
  • Type Extensions

Notable Features

slide-19
SLIDE 19

Optional Types

slide-20
SLIDE 20
  • By default variables in Swift must be initialised with a value.
  • Optional types allow those variables to be assigned a nil

value.

  • This applies to variables of any type not just object

references.

What are ? Optional Types

slide-21
SLIDE 21

Example

slide-22
SLIDE 22
  • Tony Hoare’s Billion Dollar Mistake
  • Creator of QuickSort and ALGOL W

I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object

  • riented language (ALGOL W). My goal was to ensure that

all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.

“ ”

Why Optional Types?

slide-23
SLIDE 23

Pattern Matching

slide-24
SLIDE 24

What is ?

  • No I don’t mean Regular Expressions
  • Pattern matching in Swift is provided by a switch statement

with super powers.

Pattern Matching

slide-25
SLIDE 25

Example

slide-26
SLIDE 26

Example

slide-27
SLIDE 27

Example

slide-28
SLIDE 28

Example

slide-29
SLIDE 29
  • Exception handling
  • Macros
  • Collections beyond Array & Dictionary
  • Limited RTTI/Reflection API
  • Developer definable attributes
  • No language level support for asynchronous code

Notable Omissions

slide-30
SLIDE 30

(But you should learn Objective-C too.)

Should you learn Swift?

YES!

Should you learn Swift?

slide-31
SLIDE 31

(But you should be developing something.)

Should you deliver in Swift?

Hell No!

Should you deliver in Swift?

slide-32
SLIDE 32

Thank You.

@orj