Introduction to SWIFT
A modern programming language that is safe, fast, and interactive,Swift is a powerful and intuitive programming language for iOS, OS X, tvOS, and watchOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next project — or addition into your current app — because Swift code works side-by-side with Objective-C.The Swift compiler is faster then Objective-C compiler- Error handling
- Syntax improvements
- Open source
- Modern
- Designed for safety
- Fast and Powerful
- Objective-C interoperability
Error handling model
Syntax improvements
- Powerful control flow with do, guard, defer, and repeat
- Keyword naming rules unified for functions and methods
- Protocol extensions and default implementations
- Extended pattern matching to work in if clauses and for loops
Open Source
Modern
Swift is the result of the latest research on programming languages, combined with decades of experience building Apple platforms. Named parameters brought forward from Objective-C are expressed in a clean syntax that makes APIs in Swift even easier to read and maintain.Swift has many other features to make your code more expressive:
- Closures unified with function pointers
- Tuples and multiple return values
- Generics
- Fast and concise iteration over a range or collection
- Structs that support methods, extensions, and protocols
- Functional programming patterns, e.g., map and filter
- Native error handling using try / catch / throw
Designed for Safety
Swift eliminates entire classes of unsafe code. Variables are always initialized before use, arrays and integers are checked for overflow, and memory is managed automatically. Syntax is tuned to make it easy to define your intent — for example, simple three-character keywords define a variable ( var ) or constant ( let ).Another safety feature is that by default Swift objects can never benil. In fact, the Swift compiler will stop you from trying to make or use a nil object with a compile-time error. This makes writing code much cleaner and safer, and prevents a huge category of runtime crashes in your apps. However, there are cases where nil is valid and appropriate. For these situations Swift has an innovative feature known as optionals. An optional may contain nil, but Swift syntax forces you to safely deal with it using the ? syntax to indicate to the compiler you understand the behavior and will handle it safely