1 / 14

Handybook : Swift

Handybook : Swift. Jayant Sani. Handybook Opinions. “It’s like Ruby on Rails, for iOS !” – Nikita “A function should only do one thing and return one value” - Justin. Brief History. 1983: Objective-C is created 2000: Chris Lattner starts to work on LLVM,

Download Presentation

Handybook : Swift

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Handybook: Swift Jayant Sani

  2. Handybook Opinions • “It’s like Ruby on Rails, for iOS!” – Nikita • “A function should only do one thing and return one value” - Justin

  3. Brief History • 1983: Objective-C is created • 2000: Chris Lattner starts to work on LLVM, a compiler for Objective-C during college • 2007: LLVM project releases Clang • 2010: Lattner begins working on Swift • 2012: Apple ditches GCC, giving LLVM more flexibility • 2014: Apple announces Swift at WWDC

  4. High-Level Overview • Objective-C showing age – Smalltalk syntax • Around since the 1980s • Many modifications to make it modern • Compile time vs Runtime (Static and dynamic)

  5. Modern Language Features • No semicolons! • Static type system • Optional types • Functional Programming • Closures • Tuples • Generics • Automatic Reference Counting • Extensions • REPL (Playgrounds) • Designated and Convenience Initializers*

  6. Static Type System • Objective-C: Dynamic Typing, only object type was (id) in early stages Valid Objective-C code: NSString *string = @”Handybook”; id str = string NSDictionary *dict= str; dict[@”name”] • Compiles fine, runtime error • Swift: Static Typing

  7. Guess what returns

  8. Functional • Objective-C: Blocks • F*ckingblocksyntax.com returnType (^blockName)(parameterTypes) = ^returnType(parameters) { statements }; • Swift: Functions are first class objects, Closures (param1Type, param2Type, …) -> returnType { (params) -> returnType in statements }

  9. Generics Extensions Tuples

  10. Drawbacks • Xcode 6 is very, very, very buggy – beta • Proprietary • Operator overloading – controversial • No pointers – errors, functions • Dealing with JSON Data • Message passing vs. vtable • Vague constants – “let” keyword • No access modifiers • Objective-C without Smalltalk

More Related