{"id":11926,"date":"2015-08-13T15:31:26","date_gmt":"2015-08-13T19:31:26","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=11926"},"modified":"2015-08-14T16:44:25","modified_gmt":"2015-08-14T20:44:25","slug":"objective-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/08\/13\/objective-swift\/","title":{"rendered":"Objective-Swift"},"content":{"rendered":"<p><a href=\"http:\/\/inessential.com\/2015\/08\/11\/swift_diary_11_objective-swift\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"http:\/\/inessential.com\/2015\/08\/11\/swift_diary_11_objective-swift\">\n<p>Now, these aren&rsquo;t really problems with Swift &mdash; they&rsquo;re problems with <em>pure<\/em> Swift. [&#8230;] Given that, I made the pragmatic decision to start using @objc protocols, classes, and collection types where those things make sense, where Swift fought against my design.<\/p>\n<p>And suddenly the language is a joy to use. It&rsquo;s like Objective-C but with type inference, no .h files, fewer imports, shorter syntax &mdash; <em>and<\/em> I get the things I was missing.<\/p>\n<\/blockquote>\n<p>This is my current approach as well. Swift has a lot to offer just as a better Objective-C. I&rsquo;m not enamored with generics, and protocols seem like a good idea <a href=\"http:\/\/mjtsai.com\/blog\/2015\/06\/22\/swift-protocols-question\/\">that<\/a> <a href=\"http:\/\/owensd.io\/2015\/08\/06\/protocols.html\">in<\/a> <a href=\"http:\/\/mjtsai.com\/blog\/2015\/08\/03\/swift-protocols-arrays-and-casting\/\">practice<\/a> is currently too much of a pain to use. Likewise, the standard library is still <a href=\"http:\/\/mjtsai.com\/blog\/2015\/07\/24\/strings-in-swift-2\/\">in flux<\/a> and <a href=\"http:\/\/mjtsai.com\/blog\/2015\/08\/01\/swift-array-performance\/\">not fully understood<\/a>, whereas Foundation is stable and a known quantity. Foundation is great. Why not keep using it?<\/p>\n<p>It&rsquo;s also my hunch that by staying closer to the Objective-C world you are more likely to avoid bugs and confusing error messages from the Swift compiler. And you can somewhat avoid painting yourself into a corner because any code should be relatively easy to port back to Objective-C, if necessary. It&rsquo;s <a href=\"http:\/\/stackoverflow.com\/questions\/24204211\/mixing-objective-c-and-swift-when-subclassing\">not possible<\/a> to subclass a Swift class from Objective-C, though&mdash;even if it inherits from <code>NSObject<\/code>&mdash;so hopefully you won&rsquo;t run into any problems with a leaf class.<\/p>\n<p>Update (2015-08-14): <a href=\"https:\/\/twitter.com\/jckarter\/status\/632231560398290944\">Joe Groff<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jckarter\/status\/632231560398290944\"><p>ObjC and the ObjC runtime also aren&rsquo;t going away. Using @objc for things still we suck at natively is good and encouraged.<\/p><\/blockquote>\n<p><a href=\"https:\/\/twitter.com\/wilshipley\/status\/632288794595586048\">Wil<\/a> <a href=\"https:\/\/twitter.com\/wilshipley\/status\/632288935884886016\">Shipley<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/wilshipley\/status\/632288794595586048\"><p>My intuition says they&rsquo;ll naturally wither like Carbon did. And we won&rsquo;t mind.<\/p><\/blockquote>\n<blockquote cite=\"https:\/\/twitter.com\/wilshipley\/status\/632288935884886016\"><p>But it&rsquo;s nice to hear there aren&rsquo;t plans to artificially axe ObjC.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Brent Simmons: Now, these aren&rsquo;t really problems with Swift &mdash; they&rsquo;re problems with pure Swift. [&#8230;] Given that, I made the pragmatic decision to start using @objc protocols, classes, and collection types where those things make sense, where Swift fought against my design. And suddenly the language is a joy to use. It&rsquo;s like Objective-C [&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,31,46,30,54,71,901],"class_list":["post-11926","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-languagedesign","tag-mac","tag-objective-c","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11926","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=11926"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11926\/revisions"}],"predecessor-version":[{"id":11944,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11926\/revisions\/11944"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=11926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=11926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=11926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}