Swift Introduction | Preparing to Use Swift | Swift Features
What kind of language is Swift? This article summarizes its features.
A Modern Language
Objective-C did not support many convenient features adopted by modern languages. Swift provides language features that were not available in Objective-C, including closures, which let you handle a process like a value, and generics, which let you work with different kinds of values.
A Safer Language
Swift has syntax designed to remove common sources of bugs from code. For example, variables must be initialized, optional values explicitly represent the absence of an object, variables have types from the beginning, and control-flow bodies must be enclosed in braces. These features help prevent accidental mistakes.
An Interactive Language
Swift is a compiled language. You can compile a program in advance into binary code that a computer executes directly. Swift can also run interactively. Xcode provides a playground where you can write and run statements immediately. We will use this approach to learn the basics of Swift.
Fast Execution
Because Swift includes many convenient features, you might assume that Objective-C applications run faster. However, Apple stated that programs written in Swift could run faster than Objective-C programs.
Other programmers identified bottlenecks in early versions of Swift, so it was not always possible to state that Swift was faster than Objective-C. Its performance was expected to improve as the language matured.
The Same Objective-C Backbone
Objective-C was used on macOS and iOS because the operating systems were optimized for it. The appearance of a new language such as Swift does not change that foundation. Frameworks built into macOS and iOS were created for Objective-C, and Swift uses them directly. Although the language is new, Swift developers use many of the same operating-system features that Objective-C developers used. You do not need to learn every platform feature again from the beginning. Much of your Objective-C knowledge remains useful.