Swift 5.1 released, faster and easier to use and more compatible

Swift 4

Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

The goal of the Swift project is to create the best available language for uses ranging from systems programming, to mobile and desktop apps, scaling up to cloud services. Most importantly, Swift is designed to make writing and maintaining correct programs easier for the developer. To achieve this goal, we believe that the most obvious way to write Swift code must also be:

Safe. The most obvious way to write code should also behave in a safe manner. Undefined behavior is the enemy of safety, and developer mistakes should be caught before software is in production. Opting for safety sometimes means Swift will feel strict, but we believe that clarity saves time in the long run.

Fast. Swift is intended as a replacement for C-based languages (C, C++, and Objective-C). As such, Swift must be comparable to those languages in performance for most tasks. Performance must also be predictable and consistent, not just fast in short bursts that require clean-up later. There are lots of languages with novel features — being fast is rare.

Expressive. Swift benefits from decades of advancement in computer science to offer syntax that is a joy to use, with modern features developers expect. But Swift is never done. We will monitor language advancements and embrace what works, continually evolving to make Swift even better.

Feature

  • 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
  • Powerful error handling built-in
  • Advanced control flow with doguarddefer, and repeat keywords
Changelog Swift 5.1

Module Stability

Swift 5.1 enables the creation of binary frameworks that can be shared with others leveraging the language’s added support for module stability. Module stability defines a new text-based module interface file that describes the API of a binary framework, allowing it to be compiled with code using different versions of the compiler.

The release also includes features to support library evolution. For more information about this addition to the language, please refer to the Swift Evolution proposal for Library Evolution.

Standard Library Updates

The standard library in Swift 5.1 includes the following new features:

  • Support for handling and updating diffs on collections of appropriate types
  • Increased flexibility for initializing and accessing an array before its storage is allocated
  • Additional APIs for making it easier to work with Strings, including creating and handling contiguous strings, helpers for working with Unicode text, and generic initializers for String.Index and Range
  • A variety of incremental API improvements for working with SIMD types, including support for extending vectors, reductions, and vector swizzles
  • Identifiable protocol for supporting entities that require unique identifiers

Swift 5.1 implements the following Standard Library proposals from the Swift Evolution process:

More

Download