{"id":10740,"date":"2015-02-13T16:56:33","date_gmt":"2015-02-13T21:56:33","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10740"},"modified":"2015-03-12T17:08:47","modified_gmt":"2015-03-12T21:08:47","slug":"swift-1-2","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/02\/13\/swift-1-2\/","title":{"rendered":"Swift 1.2"},"content":{"rendered":"<p><a href=\"https:\/\/developer.apple.com\/swift\/blog\/?id=22\">Apple<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/swift\/blog\/?id=22\"><p>Today Swift 1.2 was released as part of Xcode 6.3 beta. This beta release includes a significantly enhanced Swift compiler, as well as new features in the Swift language itself. For the complete list of changes, read the <a href=\"https:\/\/developer.apple.com\/devcenter\/download.action?path=\/Developer_Tools\/Xcode_6.3_beta\/Xcode_6.3_beta_Release_Notes.pdf\">release notes<\/a>.<\/p><\/blockquote>\n<p>There&rsquo;s lots of good stuff here, and it&rsquo;s really impressive how quickly Apple is moving. Some highlights are performance improvements (especially with the optimizer off), a set data type, and a <a href=\"http:\/\/nshipster.com\/swift-1.2\/\">fix<\/a> for the <a href=\"http:\/\/mjtsai.com\/blog\/2014\/12\/12\/tearing-down-swifts-optional-pyramid-of-doom\/\">pyramid of doom<\/a>.<\/p>\n\n<p><a href=\"http:\/\/www.raywenderlich.com\/95181\/whats-new-in-swift-1-2\">Greg Heo<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.raywenderlich.com\/95181\/whats-new-in-swift-1-2\"><p>In Swift 1.2, Objective-C classes that have native Swift equivalents (<code>NSString<\/code>, <code>NSArray<\/code>, <code>NSDictionary<\/code> etc.) are no longer automatically bridged. That means passing an <code>NSString<\/code> to a function that expects a <code>String<\/code> will now fail!<\/p>\n<p>[&#8230;]<\/p>\n<p>If you&rsquo;re maintaining Objective-C code, there are some new qualifiers for you to use when specifying the type for arguments, variables, properties, etc. [&#8230;] If you don&rsquo;t have Objective-C code to maintain, you&rsquo;ll still benefit from Apple adding these qualifiers to the Cocoa headers. That will make your Swift experience that much cleaner with fewer implicitly-unwrapped values.<\/p><\/blockquote>\n\n<p><a href=\"http:\/\/nshipster.com\/swift-1.2\/\">Nate Cook<\/a>:<\/p>\n<blockquote cite=\"http:\/\/nshipster.com\/swift-1.2\/\">Annotating <em>any<\/em> pointer in an Objective-C header file causes the compiler to expect annotations for the entire file, bringing on a cascade of warnings. Given that most annotations will be <code>nonnull<\/code>, a new <a href=\"http:\/\/nshipster.com\/pragma\/\"><code>#pragma<\/code> declaration<\/a> can help streamline the process of annotating existing classes. Simply mark the beginning and end of a section of your header with <code>#pragma clang assume_nonnull begin<\/code> and <code>... end<\/code>, then mark the exceptions.<\/blockquote>\n\n<p><a href=\"http:\/\/airspeedvelocity.net\/2015\/02\/11\/changes-to-the-swift-standard-library-in-1-2-beta-1\/\">Airspeed Velocity<\/a> covers changes to the standard library, such as:<\/p>\n<blockquote cite=\"http:\/\/airspeedvelocity.net\/2015\/02\/11\/changes-to-the-swift-standard-library-in-1-2-beta-1\/\"><p>Since classes in Swift are reference-counted, it ought to be possible to detect if your buffer class is being referenced by more than one struct.  But there wasn&rsquo;t an easy Swift-native way to do this, until 1.2, which introduces <code>isUniquelyReferenced<\/code> and <code>isUniquelyReferencedNonObjC<\/code> function calls[&#8230;]<\/p><\/blockquote>\n\n<p><a href=\"http:\/\/ericasadun.com\/2015\/02\/09\/swift-1-2-has-dropped\/\">Erica Sadun<\/a>:<\/p>\n<blockquote cite=\"http:\/\/ericasadun.com\/2015\/02\/09\/swift-1-2-has-dropped\/\"><p>Swift now supports building targets incrementally. HELLS yes. It no longer should re-build <em>every single file<\/em> every single time you add a new punctuation mark somewhere.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/schwa\/status\/565024482624937985\">Jonathan<\/a> <a href=\"https:\/\/twitter.com\/schwa\/status\/565041767347535872\">Wight<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/schwa\/status\/565024482624937985\"><p>Swift&rsquo;s new (NS-less) arrays no longer work with KVO.<\/p>\n<p>To be expected but rather annoying.<\/p><\/blockquote>\n<blockquote cite=\"https:\/\/twitter.com\/schwa\/status\/565041767347535872\"><p>Yeah so Swift NS-less arrays are really the kiss of death to Cocoa bindings in Swift.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/wilshipley\/status\/564941436852793344\">Wil Shipley<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/wilshipley\/status\/564941436852793344\"><p>Swift 1.2: my code code runs up to 10x faster than 1.1 unoptimized, up to 8x faster optimized.<\/p><\/blockquote>\n<p><a href=\"https:\/\/twitter.com\/owensd\/status\/564989136180756480\">David Owens II<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/owensd\/status\/564989136180756480\"><p>[Optimized] builds were still 2x~4x as slow as C in my limited tests.<\/p><\/blockquote>\n<p><a href=\"http:\/\/owensd.io\/2015\/02\/09\/swift-1.2-performance.html\">David Owens II<\/a>:<\/p>\n<blockquote cite=\"http:\/\/owensd.io\/2015\/02\/09\/swift-1.2-performance.html\">\n<p>Swift is getting better and faster but it&rsquo;s still not suitable in the domain space I&rsquo;m currently working in for this project: high-performance, real-time systems.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/schwa\/status\/565019270631788545\">Jonathan Wight<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/schwa\/status\/565019270631788545\"><p>On 1.2 Release is about 180-200% faster than Debug.<\/p>\n<p>IIRC 1.x showed larger differences between debug &amp; release.<\/p><\/blockquote>\n\n<p><a href=\"http:\/\/blog.sudeium.com\/2015\/02\/10\/swift-1-dot-2-performance-pretty-much-fine\/\">Adam Kaplan<\/a> finds that it&rsquo;s faster, though still slower than Objective-C:<\/p>\n<blockquote cite=\"http:\/\/blog.sudeium.com\/2015\/02\/10\/swift-1-dot-2-performance-pretty-much-fine\/\"><p>At this stage I&rsquo;m more than happy to retract my previous conclusion of Swift being too slow for production use. Swift 1.2 seems more than up-to the task and if they keep updates like this one coming, it may even eventually live up to its namesake.<\/p><\/blockquote>\n\n<p>It <a href=\"http:\/\/blog.impathic.com\/post\/99647568844\/debugging-slow-swift-compile-times\">still<\/a> has <a href=\"https:\/\/twitter.com\/kongtomorrow\/status\/565844856690339841\">exponential compile times<\/a> for simple literals, <a href=\"https:\/\/twitter.com\/wilshipley\/status\/564956952107548672\">IDE crashes<\/a>, and there are some new <a href=\"https:\/\/devforums.apple.com\/message\/1102454#1102454\">NSString bridging issues<\/a>.<\/p>\n<p><a href=\"https:\/\/twitter.com\/wilshipley\/status\/565001293975257091\">Wil Shipley<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/wilshipley\/status\/565001293975257091\"><p>In 1989 I saw Cocoa (nee NeXTstep) and said, &ldquo;I&rsquo;ll spend my life making it so everyone can use this.&rdquo;<\/p>\n<p>I feel that was about Swift, now.<\/p><\/blockquote>\n\n<p>Update (2015-03-10): <a href=\"http:\/\/article.gmane.org\/gmane.comp.compilers.clang.devel\/41568\">Douglas Gregor<\/a> (via <a href=\"https:\/\/twitter.com\/kongtomorrow\/status\/575448891547521024\">Ken Ferry<\/a>):<\/p>\n<blockquote cite=\"http:\/\/article.gmane.org\/gmane.comp.compilers.clang.devel\/41568\"><p>In a recent version of Xcode, Apple introduced an extension to C\/C++\/Objective-C that expresses the nullability of pointers in the type system via new nullability qualifiers . Nullability qualifiers express nullability as part of the declaration of&nbsp;strchr.<\/p>\n<p>[&#8230;]<\/p>\n<p>We&rsquo;d like to contribute the implementation (and there is a patch attached at the end), but since this is a nontrivial extension to all of the C family of languages that Clang supports, we believe that it needs to be discussed here first.<\/p><\/blockquote>\n\n<p>Update (2015-03-12): <a href=\"https:\/\/developer.apple.com\/swift\/blog\/?id=25\">Apple<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/swift\/blog\/?id=25\"><p>In general, you should look at <code>nullable<\/code> and <code>nonnull<\/code> roughly the way you currently use assertions or exceptions: violating the contract is a programmer error.<\/p>\n<p>[&#8230;]<\/p>\n<p>Nullability annotations for C and Objective-C are available starting in Xcode 6.3. For more information, see the <a href=\"http:\/\/developer.apple.com\/go\/?id=xcode-6.3-beta-release-notes\">Xcode 6.3 Release Notes<\/a>.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Apple: Today Swift 1.2 was released as part of Xcode 6.3 beta. This beta release includes a significantly enhanced Swift compiler, as well as new features in the Swift language itself. For the complete list of changes, read the release notes. There&rsquo;s lots of good stuff here, and it&rsquo;s really impressive how quickly Apple is [&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":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","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":[69,199,275,46,54,71,901],"class_list":["post-10740","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-bindings","tag-keyvalueobserving","tag-languagedesign","tag-objective-c","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10740","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=10740"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10740\/revisions"}],"predecessor-version":[{"id":10811,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10740\/revisions\/10811"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}