A Swiftcycle Built Four Two

And now that we’ve got our apps all compatible with this year’s OS and devices — you have, haven’t you? — time to take a closer look at all the goodies in the latest Swift that people have been discovering since WWDC, now that it’s official and all:

Swift 4.2 Released!

Swift 4.2 is now officially released! Swift 4.2 builds on the strengths of Swift 4, delivering faster compile times, improving the debugging experience, updating the standard library, and converging on binary compatibility.

You can watch a quick overview of it by watching the WWDC 2018: What’s New in Swift presentation, and try out some of the new features in this playground put together by Ole Begemann…

… With the completion of conditional conformance support, Swift 4.2 makes significant progress in implementing the vision of generics in the language. Watch the Swift Generics WWDC 2018 presentation for more details.

Check out those shows for sure, and read the whole thing if you want the nitty-gritty of all the implemented swift-evolution proposals, or you could just skip straight to

Migrating to Swift 4.2

Alllegedly the Xcode migrator should take care of pretty much everything, but it choked a lot for us. YMMV. Either way, not a lot of breaking changes you’re likely to find; aside from some minor renaming, check out Upgrading To Swift 4.2 for discussion, most everything new is additive — 

— and, as always, check out What’s new in Swift? for a quick and easy reference between the versions of your choice — 

— personally, our ABOUT TIME! award goes to Swift Diagnostics: #warning and #error. Good riddance, parsing scripts!

Although it’s a very close runner up for Synthesized conditional conformances in Swift 4.2. It’s just automagic!

Overdue conveniences out of the way, likely the biggest immediate aid to our coding is CaseIterable, which contrary to what the name might lead you to expect isn’t just for enums but for any type with a finite number of values: check out Enumerating enum cases in Swift for details.

Now, the biggie in terms of power, and in generating powerful opinions shall we say? centerpiece feature:

Introduce User-defined “Dynamic Member Lookup” Types

!This proposal introduces a new @dynamicMemberLookup attribute. Types that use it provide “dot” syntax for arbitrary names which are resolved at runtime – in a completely type safe way… The driving motivation for this feature is to improve interoperability with inherently dynamic languages like Python, Javascript, Ruby and others. That said, this feature is designed such that it can be applied to other inherently dynamic domains in a modular way.

On the one hand, this is definitely an “enough rope to shoot yourself in the head” kind of feature, on the other hand, Swift’s chances of ever becoming more than an Apple ghetto are enhanced significantly with this, so we figure you should all be cheering for the future job prospects! For more on this, check out

Thoughts on @dynamicMemberLookup

Exploring @dynamicMemberLookup and commentary

And while we’re speaking dynamically and all, over at Chez Wenderlich there’s an excellent overview of Dynamic Features in Swift up to and including this latest.

That’s about it for majorly interesting new stuff, but there’s some more interesting details, check out:

Ole Begemann’s above-referenced Playground: What’s new in Swift 4.2

The completely different yet identically named playground to go with Hacking With Swift’s What’s new in Swift 4.2 too.

And for yet another — come on people, we can do a creative name — Ray Wenderlich has a What’s New in Swift 4.2 three.

Michael Tsai’s Swift 4.2 Released

Finally, if you really want to get ahead of the game … check out What’s new in Swift 5.0!

UPDATES:

Bloom Filters and Swift 4.2

How CaseIterable Works Internally in Swift

Swift Associated Types With Default Values

Alex | September 21, 2018

Leave a Reply