A Swiftcycle Built Four Two
Swift 4.2 has been released! Check out this post to learn more about the new goodies in Swift, including synthesized conditional conformances and dynamic member lookups.
Join the DZone community and get the full member experience.
Join For FreeAnd now that we’ve got our apps compatible with this year’s OS and devices, it's 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 on 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 this Swift Generics WWDC 2018 presentation for more details.
Migrating to Swift 4.2
Allegedly, the Xcode migrator should take care of pretty much everything, but it choked a lot for us. Either way, you are not likely to find a lot of breaking changes; aside from some minor renaming, check out this post, Upgrading To Swift 4.2, for further discussion.
Most everything new is additive. Although it’s a very close runner-up for the synthesized conditional conformances in Swift 4.2. It’s just auto-magic!
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 this post, Enumerating enum cases in Swift, for more details.
Now, the biggie in terms of power and in generating powerful opinions, shall we say? It is this centerpiece feature:
User-Defined “Dynamic Member Lookup” Types
This proposal introduces a new @dynamicMemberLookup
attribute. Types that use it provide “dot” syntax for arbitrary names that are resolved at runtime and 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 in such a way that it can be applied to other inherently dynamic domains.
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 this post on the @dynamicMemberLookup and commentary here.
And, while we’re speaking dynamically and all, over at Chez Wenderlich, there’s an excellent overview of the dynamic features in Swift up to and including this latest release.
That’s about it for the majorly interesting new stuff, but there are some more interesting releases to check out:
Ole Begemann’s above-referenced Playground: What’s new in Swift 4.2
Ray Wenderlich has a What’s New in Swift 4.2 (part 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!
Published at DZone with permission of Alex Curylo, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments