What, Where and Why Swift SwiftCLT Meetup – 10/24/2016
What is Swift The development of Swift as a language started in the summer of 2010. Released as 1.0 in the fall of 2014. Combine the best of all languages to produce one language to rule them all.
What is Swift “Swift is a new programming language for iOS, macOS, watchOS, and tvOS apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift’s clean slate, backed by the mature and much- loved Cocoa and Cocoa Touch frameworks, is an opportunity to reimagine how software development works.” developer.apple.com
What is Swift Do a search for “What coding language is Swift most like” You will get lots of answers such as Swift syntax looks like this but functionally behaves like that. Or Swift borrowed this from Ruby, but fits more with Haskell. The point is is borrows from everywhere and this question does not have a clear answer.
What is Swift Swift was designed with a few things in mind Clarity Modern Safe Performance
What is Swift Clarity & Safe let & var – Constants and Variables No Mutable or Immutable Must have a value after init Encourages constants then vars
What is Swift Modern Type inference
What is Swift Safe Type safety Arrays must hold same type Dictionary keys must all be the same type, values must be of the same type
What is Swift Clarity & Modern Clean loops
What is Swift Modern Powerful switch statements Interval Matching
What is Swift Modern Powerful switch statements Tuples
What is Swift Modern Powerful switch statements Cases can have where clauses
What is Swift Modern Powerful switch statements Compound cases
What is Swift Clarity, Safe & Modern guard use a guard statement to require that a condition must be true in order for the code after the guard statement to be executed. Allows error handling close to where the check is defined
What is Swift Safe Optionals Hold a value or nil Designated by the ? Allow you to declare vars that don’t need a value at time of init When you go to use an optional you must unwrap it
What is Swift Clarity Optional Binding – avoid the pyramid of doom
What is Swift Modern Functions as first class citizens
What is Swift Safe Static typing - types are known at compile time, not deferred to run time All variables, constants, and functions must have their types declared in advance Type cannot change after declared
What is Swift Safe Static typing - types are known at compile time, not deferred to run time All variables, constants, and functions must have their types declared in advance Type cannot change after declared
What is Swift Safe Static typing - types are known at compile time, not deferred to run time All variables, constants, and functions must have their types declared in advance Type cannot change after declared
What is Swift Performance Value type - Except class which pass by reference optimized memory usage as well as optimized CPU cycles for fast performance Dropping legacy C conventions has greatly improved Swift under the hood Fewer name collisions with implicit namespaces
Where is Swift iOS watchOS macOS tvOS Linux https://swift.org/blog/swift-linux-port/
Where is Swift Server Side Simplify the management and deployment of your app to the cloud IBM Cloud tools for Swift is a popular Mac App, providing developers with a familiar Xcode environment to easily deploy Swift apps to. IBM Bluemix, the only cloud optimized for Swift end-to-end. developer.ibm.com
Where is Swift Android “About the time Swift was going open source, representatives for three major brands — Google, Facebook and Uber — were at a meeting in London discussing the new language. Sources tell The Next Web that Google is considering making Swift a “first class” language for Android, while Facebook and Uber are also looking to make Swift more central to their operations.” “Google’s Android operating system currently supports Java as its first-class language, and sources say Swift is not meant to replace Java, at least initially. While the ongoing litigation with Oracle is likely cause for concern, sources say Google considers Swift to have a broader “upside” than Java.” http://thenextweb.com/
Why Swift It is predicted that by 2020, 70% of the world’s population will be using smartphones. http://blog.careerfoundry.com/ In January, Swift overtook Objective-C to become the 14th most popular language in the TIOBE index. 9to5mac.com See the previous slides about Where is Swift
Why Swift Easy To Learn Easier to read: no @ or ; or [[[]]] Playground Doesn’t have to be compiled (REPL)– see results real time Clean and simple syntax, Simplifies the special characters many languages need Compile time errors and warnings Simplified memory management (ARC supported throughout)
Why Swift Easier to maintain No legacy to hold it back - not tied to C No header files No maintaining two files
Why Swift Open Source The Swift community is now driving where Swift goes Follow the updates suggestions and discussions Even suggest something yourself Could be ported to just about anywhere in the future
Why Swift Young With Swift 3.0 we really have our first stable version and it just came out
Why Swift Apple, Apple, Apple This was Apple’s baby, they are not likely to be going anywhere soon
Why Swift Because all the cool kids are doing it!