Wednesday, September 20, 2017

Swift 4.0 Released

Ted Kremenek:

Swift 4 is now officially released! Swift 4 builds on the strengths of Swift 3, delivering greater robustness and stability, providing source code compatibility with Swift 3, making improvements to the standard library, and adding features like archival and serialization.

[…]

One advantage of these language modes is that you can start using the new Swift 4 compiler and migrate fully to Swift 4 at your own pace, taking advantage of new Swift 4 features, one module at a time.

I ended up updating all of my code at once, and it took less than an hour. This is by far the smoothest major Swift update so far.

Unfortunately, the tooling is still rough. Some of the new standard library methods don’t appear in the documentation (even searching with Dash), and Xcode’s “Jump to Definition” feature is inoperable much of the time, so the only way to actually see some of the new methods is via code completion. At least with Objective-C there is an actual header file I can open or search.

Mike Ash:

We’re not getting a radical rework of the syntax like we did last year, nor are we getting a breathtaking pile of new features like we did for Swift 2, but there are some nice additions you can use to improve your code. Let’s take a look!

Ole Begemann:

An Xcode playground showcasing the new features in Swift 4.0.

Chris Eidhof:

Swift 4 really helps to clean up many examples in Advanced Swift[…]

Previously: Swift.Codable, Swift 4: Key-Value Observation, Swift’s Error Handling Implementation, Swift 4: Bridging Peephole for “as” Casts, Swift 4: Synthesizing Equatable and Hashable Conformance, Swift 4: JSON With Encoder and Encodable, Swift 4 String Manifesto, Provide Custom Collections for Dictionary Keys and Values.

Update (2017-09-25): See also: Updating Strings For Swift 4.

Update (2017-10-04): Nate Cook:

In the latest release of Swift, dictionaries and sets gain a number of new methods and initializers that make common tasks easier than ever. Operations like grouping, filtering, and transforming values can now be performed in a single step, letting you write more expressive and efficient code.

This post explores these new transformations, using some grocery data for a market as an example.

1 Comment RSS · Twitter

Leave a Comment