Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift (Not TSwift)

Swift (Not TSwift)

Swift is a new language developed for iOS and Mac OS applications. In this presentation, VM Farms Inc.'s Anarosa Paredes outlines some of its major features, for the company's Friday Tech Demo series.

VM Farms Inc.

July 17, 2014
Tweet

More Decks by VM Farms Inc.

Other Decks in Programming

Transcript

  1. Agenda 1. What is it? a. Brief description/history b. Features

    2. Where does it fit in in the stack? 3. How is it special? 4. What would I use it for?
  2. What is it? Language invented by Apple™ Development started in

    2010 Announced and released 2014 “Objective-C without the C”
  3. What Is It? - Features Multi-paradigm language Object oriented Functional

    programming Imperative Block-structured Original source: cbeust - “Apple Swift Programming Language Unveiled” Reddit.com
  4. What Is It? - Features Static Typing Verifies variable types

    before runtime Inferred Automatically infers variable types, based on the context they’re used in There’s no need to import libraries for input/output or handling strings Source: cbeust - “Apple Swift Programming Language Unveiled” Reddit.com
  5. What Is It? - Features Generics Functions that work with

    any type Source: iOS Developer Library - Swift Language Guide - “The Problem That Generics Solve” On the left is a function that is built to swap two integers. Floats would be invalid inputs. On the right, the same function is implemented as a Generic. Ints and floats are both now valid input types.
  6. What Is It? - Features Unicode variables Variable names could

    be in non- Latin character languages Closures Used for functional programming No exceptions Like C Image source: Global Nerdy Source: cbeust - “Apple Swift Programming Language Unveiled” Reddit.com
  7. What Is It? - Features Extension methods Properties associate values

    with a particular class, structure, or enumeration (great for OOP) Observers willSet and didSet Enums a common type for a group of related values Optional chaining with "a?.b?.c" Forced dereference with "!."". Original source: cbeust - “Apple Swift Programming Language Unveiled” Reddit.com
  8. What Is It? - Features Sources: cbeust - “Apple Swift

    Programming Language Unveiled” Reddit.com, “Downcasting” Wikipedia Convenient "assign and test" if let person = findPerson() ... Type casting with is (e.g. change a variable type from int to float) Down casting with as? downcasting is the act of casting a reference of a base class to one of its derived classes
  9. Where Does It Fit In? Cocoa Cocoa Touch OS X

    iOS Foundation Kit, Application Kit, and Core Data frameworks, C standard library, Objective-C runtime App Swift XCode Image source: iOS Developer Library - “What is Cocoa?”
  10. How Is It Special? Designed to be fast ...most of

    the time “Sorting a 1 million random integers array took 6 seconds when using Swift, versus 0.06 seconds when using C++, and 0.6 seconds when using Python.” http://www.infoq.com/news/2014/06/apple-swift-performance-hit However, can get speeds comparable to C when an “aggressive” compile optimizer flag (-0fast) is used
  11. How Is It Special? Open Playground Emulates the convenience dynamic

    languages (like Python) using a Playground. • A playground is an interactive environment • Run your code immediately to test behaviour • No need to compile the entire app/environment. Playgrounds allow Swift to behave like a dynamic language, instead of a static one.
  12. How Is It Special? Open Playground The open playground evaluates

    your code on the fly and displays code results in a sidebar Source: iOS Developer Library - Exploring and Evaluating Swift code in a playground
  13. What Would I Use It For? Programming within Apple™ ecosystems

    • Creating iOS-exclusive apps • Creating Mac OS applications