swift swiftly
play

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


  1. Swift Swiftly A quick introduction to the Swift language Oliver Jones Technical Director

  2. Disclaimer

  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

  4. What is Swift?

  5. What is Swift? • 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

  6. What is Swift? Objective-C without C

  7. What is Swift? Rusty Objective-C#++

  8. What is Swift? Swift IS NOT Objective-C (with new syntax)

  9. Swift Code

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

  11. Notable Features • Bridges seamlessly to C & Objective-C (mostly)

  12. Notable Features • Type Inference & Explicitly mutable/immutable variables.

  13. Notable Features • Generics

  14. Notable Features • Operator Overloading

  15. Notable Features • Classes/Reference Types (objects) & Value Types (structs, enums)

  16. Notable Features • First Class Functions & Closures

  17. Notable Features • Tuples

  18. Notable Features • Type Extensions

  19. Optional Types

  20. What are ? Optional Types • 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.

  21. Example

  22. Why Optional Types? • 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 oriented 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. ”

  23. Pattern Matching

  24. What is ? Pattern Matching • No I don’t mean Regular Expressions • Pattern matching in Swift is provided by a switch statement with super powers.

  25. Example

  26. Example

  27. Example

  28. Example

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

  30. Should you learn Swift? Should you learn Swift? YES! (But you should learn Objective-C too.)

  31. Should you deliver in Swift? Should you deliver in Swift? Hell No! (But you should be developing something.)

  32. Thank You. @orj

Recommend


More recommend