{"id":36261,"date":"2022-06-17T15:49:22","date_gmt":"2022-06-17T19:49:22","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=36261"},"modified":"2022-07-06T14:25:18","modified_gmt":"2022-07-06T18:25:18","slug":"swift-5-7-announced","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/06\/17\/swift-5-7-announced\/","title":{"rendered":"Swift 5.7 Announced"},"content":{"rendered":"<p><a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110354\/\">What&rsquo;s new in Swift<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110354\/\"><p>We&rsquo;ll take you through performance improvements, explore more secure and extensible Swift packages, and share advancements in Swift concurrency. We&rsquo;ll also introduce you to Swift Regex, better generics, and other tools built into the language to help you write more flexible &amp; expressive code.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110352\/\">Embrace Swift generics<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110352\/\"><p>Generics are a fundamental tool for writing abstract code in Swift. Learn how you can identify opportunities for abstraction as your code evolves, evaluate strategies for writing one piece of code with many behaviors, and discover language features in Swift 5.7 that can help you make generic code easier to write and understand.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110353\/\">Design protocol interfaces in Swift<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110353\/\"><p>Learn how you can use Swift 5.7 to design advanced abstractions using protocols. We&rsquo;ll show you how to use existential types, explore how you can separate implementation from interface with opaque result types, and share the same-type requirements that can help you identify and guarantee relationships between concrete types<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110356\/\">Meet distributed actors in Swift<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110356\/\"><p>Discover distributed actors &mdash; an extension of Swift&rsquo;s actor model that simplifies development of distributed systems. We&rsquo;ll explore how distributed actor isolation and location transparency can help you avoid the accidental complexity of networking, serialization, and other transport concerns when working with distributed apps and systems.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110350\/\">Visualize and optimize Swift concurrency<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110350\/\"><p>Learn how you can optimize your app with the Swift Concurrency template in Instruments. We&rsquo;ll discuss common performance issues and show you how to use Instruments to find and resolve these problems. Learn how you can keep your UI responsive, maximize parallel performance, and analyze Swift concurrency activity within your app.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110351\/\">Eliminate data races using Swift Concurrency<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110351\/\"><p>Join us as we explore one of the core concepts in Swift concurrency: isolation of tasks and actors. We&rsquo;ll take you through Swift&rsquo;s approach to eliminating data races and its effect on app architecture. We&rsquo;ll also discuss the importance of atomicity in your code, share the nuances of <code>Sendable<\/code> checking to maintain isolation, and revisit assumptions about ordering work in a concurrent system.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110355\/\">Meet Swift Async Algorithms<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2022\/110355\/\"><p>Discover the latest open source Swift package from Apple: Swift Async Algorithms. We&rsquo;ll explore algorithms from this package that you can use with <code>AsyncSequence<\/code>, including <code>zip<\/code>, <code>merge<\/code>, and <code>throttle<\/code>. Follow along with us as we use these algorithms to build a great messaging app. We&rsquo;ll also share best practices for combining multiple <code>AsyncSequences<\/code> and using the Swift <code>Clock<\/code> type to work with values over time.<\/p><\/blockquote>\n\n<p>&#8226; &#8226; &#8226;<\/p>\n\n<p><a href=\"https:\/\/twitter.com\/slava_pestov\/status\/1533900187701223431\">Slava Pestov<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/slava_pestov\/status\/1533900187701223431\"><p>Xcode 14 ships with Swift 5.7, which brings massive improvements to generics and protocols! &#x1F9F5;<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/www.swiftbysundell.com\/articles\/swifts-new-shorthand-optional-unwrapping-syntax\/\">John Sundell<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.swiftbysundell.com\/articles\/swifts-new-shorthand-optional-unwrapping-syntax\/\">\n<p>Swift 5.7 introduces a new, more concise way to unwrap optional values using <code>if let<\/code> and <code>guard let<\/code> statements.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/www.donnywals.com\/whats-the-difference-between-any-and-some-in-swift-5-7\/\">Donny Wals<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.donnywals.com\/whats-the-difference-between-any-and-some-in-swift-5-7\/\">\n<p>While it sounds like the <code>any<\/code> keyword acts as a <a href=\"https:\/\/www.donnywals.com\/understanding-type-erasure-in-swift\/\">type erasing<\/a> helper, all it really does is inform the compiler that you opt-in to using an existential (a box type that conforms to a protocol) as your type.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/www.donnywals.com\/what-are-primary-associated-types-in-swift-5-7\/\">Donny Wals<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.donnywals.com\/what-are-primary-associated-types-in-swift-5-7\/\">\n<p>In Swift 5.7, protocols can specify primary associated types. These associated types are a lot like generics. They allow developers to specify the type for a given associated type as a generic constraint.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/www.swiftbysundell.com\/articles\/referencing-generic-protocols-with-some-and-any-keywords\/\">John Sundell<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.swiftbysundell.com\/articles\/referencing-generic-protocols-with-some-and-any-keywords\/\">\n<p>Thankfully, this is a problem that Swift 5.7 neatly solves by expanding the <code>some<\/code> keyword (that was introduced back in Swift 5.1) to also be applicable to function arguments.<\/p>\n<p>[&#8230;]<\/p>\n<p>Swift 5.7 once again introduces a much more lightweight way to express the above kind of declaration, which works the exact same way as when specializing a <em>concrete<\/em> generic type (such as <code>Array&lt;Article&gt;<\/code>). That is, we now can simply tell the compiler what <code>Element<\/code> type that we&rsquo;d like our input <code>Collection<\/code> to contain by adding that type within angle brackets right after the protocol name[&#8230;]<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/krzyzanowskim\/status\/1536320303982432256\">Marcin Krzyzanowski<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/krzyzanowskim\/status\/1536320303982432256\">\n<p>&ldquo;Any UIKit subclass that uses <code>deinit<\/code> now essentially <a href=\"https:\/\/forums.swift.org\/t\/cannot-access-property-with-a-non-sendable-type-from-non-isolated-deinit\/57877\">causes warnings<\/a> in Swift 5.7 while they are never touched on other threads anyways.&rdquo;<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/lorentey\/status\/1533912073326825472\">Karoy<\/a> <a href=\"https:\/\/twitter.com\/lorentey\/status\/1536422480415313920\">Lorentey<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/lorentey\/status\/1533912073326825472\"><p>(<code>Set<\/code> now uses the new Temporary Buffers feature to make operations like <code>intersect<\/code> up to 4-6x faster.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/06\/17\/swiftui-changes-at-wwdc-2022\/\">SwiftUI Changes at WWDC 2022<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/06\/10\/swift-regex\/\">Swift Regex<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/06\/14\/swift-charts\/\">Swift Charts<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/06\/09\/xcode-14-announced\/\">Xcode 14 Announced<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/03\/16\/swift-5-6-released\/\">Swift 5.6 Released<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/05\/12\/fixing-swifts-if-let-syntax\/\">Fixing Swift&rsquo;s &ldquo;if let&rdquo; Syntax<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/09\/25\/swift-5-preview\/\">Swift 5 Preview<\/a><\/li>\n<\/ul>\n\n<p id=\"swift-5-7-announced-update-2022-07-06\">Update (2022-07-06): <a href=\"https:\/\/www.swift.org\/blog\/swift-language-updates-from-wwdc22\/\">Matthaus Woolard and Natalia Panferova<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.swift.org\/blog\/swift-language-updates-from-wwdc22\/\">\n<p>This post highlights some of the Swift updates that caught our attention this WWDC.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>What&rsquo;s new in Swift: We&rsquo;ll take you through performance improvements, explore more secure and extensible Swift packages, and share advancements in Swift concurrency. We&rsquo;ll also introduce you to Swift Regex, better generics, and other tools built into the language to help you write more flexible &amp; expressive code. Embrace Swift generics: Generics are a fundamental [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2022-06-17T19:49:25Z","apple_news_api_id":"02cb4b31-7110-4e6c-8316-53661d1cf474","apple_news_api_modified_at":"2022-07-06T18:25:22Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAQ==","apple_news_api_share_url":"https:\/\/apple.news\/AAstLMXEQTmyDFlNmHRz0dA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[1750,800,46,71,2200,901,1221],"class_list":["post-36261","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-apple-event","tag-concurrency","tag-languagedesign","tag-programming","tag-swift-concurrency","tag-swift-programming-language","tag-wwdc"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=36261"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36261\/revisions"}],"predecessor-version":[{"id":36444,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36261\/revisions\/36444"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=36261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=36261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=36261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}