HomeAppleList of New Features in Apple’s Swift 5 language

    List of New Features in Apple’s Swift 5 language

    The introduction of the Swift programming language has been the most significant change to Apple’s developer ecosystem. Now with the release of Swift version 5, Apple reached another major milestone.

    Swift is Apple’s open-source, fast, safe and general-purpose programming language with full stack capabilities. It aims at replacing C-based languages like C, C++, and Objective-C for everything from systems programming to mobile and desktop apps. You can use Swift to develop programs for iOS, macOS, watchOS, tvOS, and Linux. It also works with Apple’s Cocoa and Cocoa Touch frameworks and with many other existing Apple Objective-C code.

    TIOBE Index featured Swift as one of the top 10 programming languages within the two years of its launch. In fact, Swift became the fastest growing language in the history of the TIOBE Index. This was a remarkable achievement. Swift quickly gained traction among ios app developers. When Apple launched Swift in 2014, it called it the “Objective-C without C”.

    The idea for developing this programming language was to make the ios app development task easier for ios app developers to create iOS apps. The very nature of the Swift programming language enables ios app developers to code faster than coding with Objective-C. In the meanwhile, Swift eradicates the compatibility issues that had existed while coding with Objective-C.


    The need for Apple’s Swift 5 language

    In 2015 StackOverflow Developer Survey, Swift emerged as the “most loved” languages for iOS app development. Swift is simple, clean, yet expressive language with simplified grammar and syntax, making it easy to pick up even by a novice. It is also concise contributing to a significant reduction in ios app development time because it requires a lesser volume of code to perform a task. Swift is less error prone owing to better error handling capabilities and enhanced typing system. As a result, there are lesser code crashes compared to Objective-C. This also translates into quick bug fixing and prevents deployment of low-quality code.

    Swift offers better performance. When Apple launched Swift, it claimed that apps will display up to 40% spike in performance compared to Objective-C. With the use of dynamic libraries, there is lesser memory footprint. Absence of static libraries means the memory is never clogged up. Swift also offered cross-device support. This means if you master Swift, you can not only develop iOS application for iPhones and iPads, but you can use it for the full span of Apple devices including Mac, Apple Watch, and Apple TV. Interestingly it also supports Linux and enjoys a large and vibrant developer community. There is a massive contribution from ios app developers for fixing bugs, adding more useful features and enhancing the language itself.

    However, there were some obvious drawbacks with the previous versions of Swift which it tries to address through Swift 5. The biggest of them all is the ABI Stability Manifesto which tries to accomplish below goals.

    The source compatibility – Version-lock has crippled the older version of Swift. The newer compilers with Swift 5 can compile code written in an older version of Swift.

    Binary framework & runtime compatibility – Swift5 enables the distribution of frameworks in a binary form that can work across multiple Swift versions. It will achieve Binary framework compatibility through module format stability, which will help it stabilize the module file.

    The biggest issue with Swift is that its application binary interface (ABI), is not stable. This is simple terms means, Apple can’t include the Swift language support in its operating systems. That’s because an app written with Swift 3 will not work with the language support binaries for Swift 4.

    This will be changing with Apple’s Swift 5 language!


    The ABI stability and its importance?

    As we have already discussed that the main reason for Apple’s Swift 5 language is to establish Application Binary Interface stability across Apple platforms like macOS, iOS, watchOS, and tvOS.

    This means, with the newer version, Swift as a programming language has matured to the point where it no longer requires a huge change in the way its compiler works. This means the future versions can produce binaries conforming to the stable ABI. The stable ABI will persist for the rest of the platform’s lifetime.

    To understand this in simple terms means the code compiled with today’s compiler does not require recompilation again for it to work reliably with dynamically linked libraries compiled in future versions of Swift.

    This eliminates the need to bundle a known version of the standard libraries they use. The app can freely use any updated version of Swift provided by the OS. This is already happening with apps written in Objective C. Now it’s possible even with App written in Swift with the advent of Swift 5.


    Key Swift 5 features

    Here are the Key Swift 5 features:

    Swift binaries interact with other libraries and components at runtime through an ABI (Application Binary Interfaces).

    The versions older than Swift 5 are not ABI stable. Therefore each binary (App), bundles its own version of Swift Dynamic Library. With Swift 5, the ios app developers no more require to bundle the binary (App) with their own version of Swift Dynamic Library. In the older version, the Swift does not live on the iOS Operating System, but within each App. Swift 5 has addressed this.

    With ABI stability, the Swift will live within the iOS Operating System and therefore its ABI will be comfortable with every version of the Swift.

    The programming language is not binary compatible with earlier Swift releases. But now no the future Swift releases will be binary compatible with Swift 5. The Binary compatibility allows Swift code compiled by different versions of Swift compilers to link together and interoperate at a runtime level.


    The main focus for Swift 5.0

    Apple’s main focus always remained ABI stability for Swift 5.0. As we had discussed above that the Application Binary Interface (ABI) isn’t stable for Swift versions lower than 5. Apple has fixed this in Swift 5. Since in the previous versions of Swift, Application Binary Interface (ABI) was not stable, it was not possible to ship it as part of iOS, like other frameworks and libraries.

    But now since Swift has achieved stability in Application Binary Interface (ABI), Apple will ship Swift 5 as part of iOS. Any future compilers of Swift will be able to produce binaries that can run on the stable ABI that’s part of iOS.

    In the older versions of Swift, instead of connecting to the OS, every Swift based iOS app links to their own specific version of Swift. This has changed with Swift 5.0

    This means now you can continue to develop apps with Swift while the Swift itself will be actively developed and still you won’t run into the risk of ABI incompatibility. Apple will distribute the changes to Swift without updating iOS and that’s the beauty of Application Binary Interface (ABI) stability.


    New features update to the Swift programming language

    Swift 5.0 supports callable types dynamically to improve interoperability with languages such as JavaScript, Python, and Ruby.

    The new ios app development enforces exclusive access to memory for release and debugs builds. This is beneficial from Swift’s safety enhancement perspective.

    Swift 5.0 follows re-implementation of String, enforcement of exclusive access to memory, and new data types during run time.

    Apple has re-implemented the string with UTF-8 encoding instead of UTF-16, in the standard library to enhance code speed. However, Swift stills inherit Objective-C’s interoperability.

    There is an enhancement in string literals delimiters to support the raw text. Now single-line and multi-line string literals work in Swift 5.0 and can contain any content.

    Unicode has advanced text processing to them. Scalar type to support common.

    To support common and advanced text processing, the Unicode. Scalar type maintains Unicode properties.

    The library exposes a subset of operations on the SIMD types and most processors in the library support this.

    Swift has made significant performance improvements to Dictionary and Set.

    The programming language improves error handling through the addition of a Result type.

    Swift Package Manager provides target-specific build settings, customized deployment targets, dependency mirroring and the ability to generate code coverage data.

    iOS app developers can use the run command to import libraries in a read-event-print loop (REPL) without building an executable.


    Other updates to the Swift programming language

    The developer community can propose and discuss the changes to the Swift programming language on a GitHub repository called Swift Evolution. This is a very welcoming move for Swift developers.

    This will enable anyone the ability to propose changes to the language. However, there’s a process that the developer community will need to follow. For example, many proposed changes are first discussed in the Swift Forums, and in communities beyond.

    The swift core team will review all the proposed changes publicly. The Swift core team consists of (former) Apple engineers like Chris Lattner and Ted Kremenek. You can find the list of all current and past proposals on Swift Evolution, in the proposals directory.

    Editor's Pick

    Ecbert Malcom
    Ecbert Malcom
    I am a resident author at Broodle.
    Notify of

    Inline Feedbacks
    View all comments