Swift 4.2 officially released: generic improvements, faster and more compatible

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
Swift 4.2 is now officially released! Swift 4.2 is based on the benefits of Swift 4, providing faster compilation time, improved debugging experience, updated standard libraries, and converged binary compatibility.
Generic improvement
With support for conditional conformance, Swift 4.2 has made significant advances in genetics, such as reducing the number of boilerplate code, making more code reusable, and more. To learn more about conditional conformance, see more here.
Standard library update
The standard library in Swift 4.2 includes many new features, such as improvements to the Hashable protocol and new unified randomization functions and protocol sets.

Swift 4.2 includes a number of improvements that have a noticable impact on developer experience, including:

  • Support for batch mode compilation resulting in faster build times
  • Change in calling convention for retain/release cycle to reduce code size and improve runtime performance
  • Lazier SIL deserialization with -Onone
  • Recursive metadata support
  • More compact reflection metadata
  • Default arguments are inlined at call sites
  • Some long-standing bug fixes, including init declname, switch with multiple case labels per block, inheritance of generic initializers, and more.

More

Download