Swift is a new programming language for iOS, OS X, watchOS, tvOS and Linux development created by Apple Inc. Swift retains the best features of its predecessors, Objective-C and C languages, without the constraints of C compatibility.
This means that if you want to develop applications for Apple devices, you will need to know how to work with Apple’s new programming language — Swift.
What is Swift?
Swift is a multi-paradigm (protocol-oriented, object-oriented, functional, imperative, block structured), compiled programming language designed to work with Apple’s Cocoa and Cocoa Touch frameworks and existing Objective-C code written for Apple devices and platforms.
Swift is a very fresh, high-performance general purpose programming language built with a modern approach to performance, safety, and software design. Although it is inspired by Objective-C, C#, CLU, Python, Rust, Ruby and many other programming languages, Swift is not a C-derived language.
As of December 3, 2015, Swift is open source. It was published under the Apache 2.0 license with a Runtime Library Exception It includes supporting libraries, a debugger, and package manager. The source code is hosted on GitHub.
Swift development work was started in July 2010 by Chris Lattner in collaboration with many other programmers at Apple. A beta version of Swift was released to registered Apple developers at the Worldwide Developers Conference (WWDC) on June 2, 2014. Swift 1.0 was released together with the Xcode 6.0 for iOS on September 9, 2014.
Version 2.2 was made open source and published under the Apache License 2.0 on December 3, 2015. The Swift 3.0 roadmap was also announced on the Swift blog that same day.
According to Swift.org, the goal of the Swift project is to create the best available language for uses ranging from systems programming, to mobile and desktop apps, and scaling up to cloud services. Writing Swift code also has to be safe, fast and expressive.
Many features that make code easier to read and write are included in Swift. Inferred types are supported in Swift, and modules eliminate headers and provide namespaces. Additional features of Swift include: automatic memory management, closures unified with function pointers, tuples and multiple return values, generics, concise iterations over a range or collection, structs that support methods, extensions and protocols; functional programming patterns, advanced control flow with do, guard, defer, and repeat keywords; powerful error handling, etc.
Apple also made significant efforts in aggressive optimization that can flatten out method calls and accessors and improve Swift performance. Swift introduces the concept of protocol extensibility that can be applied to classes, structs and types, referred to as protocol-oriented programming.
Getting Started with Swift
If you are coming to Swift with an Objective-C and Apple platforms development background, you should expect an easy transition to Swift in a familiar environment. Swift is also friendly to new programmers with its expressive syntax.
Your Development Environment
Before you start coding in Swift, you’ll need to get your development environment set up. Currently supported host development operating systems are OS X, Ubuntu Linux LTS and the latest Ubuntu Linux release.
For OS X operating systems, the latest Xcode is required.
For Ubuntu operating systems, you will need the following dependencies:
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config
We have searched the web for the best Swift tutorials, ebooks, and interactive courses. Our recommendation is that you make use of several of these resources and work your way through them in the manner that best fits your learning style.
Free Interactive Courses
Just reading about a programming language will not be enough to learn it. To really learn what the Swift language can do, you have to see it in action. Free interactive courses provide a good starting point to learning the basic syntax of a programming language.
However, since Swift is a very young and fresh programming language, we singled out only one free interactive course and one commercial course:
- Introduction to Swift for Non-Programmers from Udemy: This is a free course that will introduce you to the basics of Swift programming, even if you do not have prior programming experience.
- Learn Swift by teamtreehouse.com offers detailed video lessons and courses covering Swift programming. This is not a free service, though.
Tutorials and official programming language reference with sample code can help you a lot in getting to grips with Swift programming. These are some of the most comprehensive and detailed resources on Swift:
- Official Swift Presentations, Documentation and Sample Code: This is an extensive collection of free official Swift guides and references, sample code, videos, lessons and iTunes U Courses.
- IBM Swift Sandbox is an interactive website that lets you write and execute Swift code in your browser.
- LearnSwift is a collection of sources for tutorials, videos and libraries for Swift.
- Swift Tutorials at Raywenderlich.com has a nice selection of Swift tutorials, some of them are free. These free tutorials can still show you a lot about Swift programming, without going for the commercial ones.
- Learn Swift, Build Your First iOS Game. Bloc is offering Swiftris, a step-by-step process that takes you through the basics of Swift in 11 segments while you build your own 2D puzzle game. E-mail registration is required.
- Apple Swift Programing Language Tutorial Series can be viewed on YouTube. It is a collection of 11 videos covering Swift programming.
If you successfully make it through some of the resources and tutorials listed above, you will surely master the basics of Swift programming, and probably much more.
We decided to single out two free ebooks about Swift programming, both are published by Apple and free. These ebooks will surely come in handy as a reference while programming in Swift:
- The Swift Programming Language by Apple: a thorough introduction, guide, and reference for the Swift language.
- Using Swift with Cocoa and Objective-C by Apple: a document focusing on Swift programming language interoperability with Cocoa API and Objective-C language.
Swift is a new and powerful programming language for creating programs and apps for Apple devices. We’ve provided you with the resources you need to become a successful Swift programmer and ride the wave of the future.