Looking Back on Swift 3 and Ahead to Swift 4

Datetime:2016-08-23 04:14:41          Topic: Swift           Share

While Swift 3 is nearing its late 2016 release, Apple’s Developer Tools Department senior director Chris Lattner provided a retrospective on its development and set expectations for Swift 4 in a long message to the Swift-evolution mailing list.

Looking back on Swift 3, Lattner mostly focuses on the benefits and drawbacks of open source development. In particular, he says, “open design” is slower and less predictable than “close design”, but the end result is “significantly better”. It is important for the community to keep focus on a limited number of topics and for the core team to be involved in key discussions up front. Additionally, he says, having specific goals helps keep focus and avoid sub-projects that end up out of scope.

Based on that, Lattner explains that Swift 4 will have two major goals: “to deliver on the promise of source stability from 3.0 on, and to provide ABI stability for the standard library”. Therefore, in a first phase which will foreseeably keep the core team busy until Spring 2017, work will primarily be on features that can affect existing ABI or cause major changes to existing standard library features. Here are some of the features that the core team has prioritized for Stage 1:

  • Source stability features, such as a -std=swift3 compiler flag, a way to conditionally enable larger efforts that are under development but not yet stable, etc.

  • Resilience, to provide a way for public APIs to evolve over time while not breaking ABI stability.

  • Generics improvements needed by the standard library, such as conditional conformances , recursive protocol requirements , and others.

  • String re-evaluation, aimed to improve Swift string programming model and put it on a par with Perl’s.

  • Memory ownership model (opt-in), inspired byCyclone/ Rust memory ownership model and aiming to provide a predictable and deterministic performance. More details here .

In a second phase, as Stage 1 reaches its peak, new features will be scoped and planned based on how much time is left. Some features that could be considered in Stage 2 are:

  • Reflection, including an user-facing API for data and method reflection.

  • First class concurrency, including actors, async/await, atomicity, memory model, and related topics. Unfortunately, as Lattner says, a new concurrency model will not be done in time for the Swift 4 release.

  • More generics improvements, as described in the generics manifesto , that are not specifically required for ABI stability.

  • .swiftmodule stability, aimed to allow 3rd-party binary frameworks.

  • New scripting features, such as regular expressions, multi-line string literals, etc.

  • Property behaviors , aiming to provide a flexible model to define property behaviors such as lazy , observers, synchronization, etc., outside of the language core.

Finally, says Lattner, there are a lot more features that could be considered for Stage 2, such as submodules, implicit promotions between numeric types, importing C++ APIs, hygienic macro system, guaranteed tail calls, making enums enumerable, typed ‘throws’, user defined attributes, abstract methods/classes, better SIMD support, data parallelism support, higher kinded types, etc.

The core team expects to ship Swift 4 sometime in Fall 2017.





About List