{"id":13281,"date":"2016-01-13T10:53:55","date_gmt":"2016-01-13T15:53:55","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=13281"},"modified":"2016-02-03T09:35:04","modified_gmt":"2016-02-03T14:35:04","slug":"better-translation-of-objective-c-apis-into-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/01\/13\/better-translation-of-objective-c-apis-into-swift\/","title":{"rendered":"Better Translation of Objective-C APIs Into Swift"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0005-objective-c-name-translation.md\">Proposal SE-0005<\/a> has been accepted:<\/p>\r\n<blockquote cite=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0005-objective-c-name-translation.md\"><p>This proposal describes how we can improve Swift&rsquo;s &ldquo;Clang Importer&rdquo;, which is responsible for mapping C and Objective-C APIs into Swift, to translate the names of Objective-C functions, types, methods, properties, etc. into names that more closely align with the <a href=\"https:\/\/swift.org\/documentation\/api-design-guidelines.html\" title=\"API Design Guidelines\">Swift API Design Guidelines<\/a> being developed as part of Swift 3. Our approach focuses on the differences between the Objective-C <a href=\"https:\/\/developer.apple.com\/library\/mac\/documentation\/Cocoa\/Conceptual\/CodingGuidelines\/CodingGuidelines.html\" title=\"Coding Guidelines for Cocoa\">Coding Guidelines for Cocoa<\/a> and the Swift API Design Guidelines, using some simple linguistic analysis to aid the automatic translation from Objective-C names to more &ldquo;Swifty&rdquo; names.<\/p><\/blockquote>\r\n<p>The new names will not be as Googleable, and this may make switching back and forth between Swift and Objective-C more difficult. But I think it&rsquo;s a good move to leverage the type system to make the APIs more concise, but not overly so.<\/p>\r\n<p>Update (2016-02-03): <a href=\"http:\/\/article.gmane.org\/gmane.comp.lang.swift.evolution\/5503\/match=nate+cook\">Nate Cook<\/a>:<\/p>\r\n<blockquote cite=\"http:\/\/article.gmane.org\/gmane.comp.lang.swift.evolution\/5503\/match=nate+cook\"><p>This is a concurring opinion with Drew\u2019s review, agreeing that we should reconsider removing the \u201cNS\u201d prefix but providing my own reasons. The proposal as a whole is exciting and far-reaching, but this particular change is misguided.<\/p><p>1) The change will elide the different semantic expectations for Foundation and Swift standard library types.<\/p><p>[\u2026]<\/p><p>2) The change may stifle the development of more Swift-oriented APIs.<\/p><p>[\u2026]<\/p><p>3) The change will make it harder to find information about the revised APIs.<\/p><\/blockquote>\r\n<p><a href=\"http:\/\/article.gmane.org\/gmane.comp.lang.swift.evolution\/5503\/match=nate+cook\">Drew Crawford<\/a>:<\/p>\r\n<blockquote cite=\"http:\/\/article.gmane.org\/gmane.comp.lang.swift.evolution\/5503\/match=nate+cook\"><p>No, the elimination of 2 characters is not significant enough of a problem to break all Swift programs, let alone to introduce literally thousands of new opportunities for shadowing.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Proposal SE-0005 has been accepted: This proposal describes how we can improve Swift&rsquo;s &ldquo;Clang Importer&rdquo;, which is responsible for mapping C and Objective-C APIs into Swift, to translate the names of Objective-C functions, types, methods, properties, etc. into names that more closely align with the Swift API Design Guidelines being developed as part of Swift [&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-13281","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\/13281","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=13281"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13281\/revisions"}],"predecessor-version":[{"id":13408,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13281\/revisions\/13408"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=13281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=13281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=13281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}