{"id":25000,"date":"2019-04-15T17:03:08","date_gmt":"2019-04-15T21:03:08","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=25000"},"modified":"2019-04-15T17:03:08","modified_gmt":"2019-04-15T21:03:08","slug":"library-evolution-for-stable-swift-abis","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/04\/15\/library-evolution-for-stable-swift-abis\/","title":{"rendered":"Library Evolution for Stable Swift ABIs"},"content":{"rendered":"<p><a href=\"https:\/\/forums.swift.org\/t\/pitch-library-evolution-for-stable-abis\/23026\">Ben Cohen<\/a>:<\/p>\n<blockquote cite=\"https:\/\/forums.swift.org\/t\/pitch-library-evolution-for-stable-abis\/23026\"><p>One of Swift&rsquo;s goals is to be a good language for libraries with binary compatibility concerns, such as those shipped as part of Apple&rsquo;s OSs. This includes giving library authors the flexibility to add to their public interface, and to change implementation details, without breaking binary compatibility. At the same time, it&rsquo;s important that library authors be able to opt out of this flexibility in favor of performance.<\/p><p>This proposal introduces:<\/p><ul><li>a &ldquo;library evolution&rdquo; build mode for libraries that are declaring ABI stability, which preserves the ability to make certain changes to types without breaking the library&rsquo;s ABI; and<\/li><li>an attribute for such libraries to opt out of this flexibility on a per-type basis, allowing certain compile-time optimizations.<\/li><\/ul><p>The mechanisms for this are already in place, and were used to stabilize the ABI of the standard library. This proposal makes them features for use by any 3rd-party library that wishes to declare itself ABI stable.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/gparker\/status\/1117329884185915394\">Greg Parker<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/gparker\/status\/1117329884185915394\">\n<p>This feature is one of the reasons that Apple created Swift instead of adopting an existing language. We needed at least as much capability to evolve libraries as Objective-C provided.<\/p>\n<\/blockquote>\n\n<p>Previously: <a href=\"https:\/\/mjtsai.com\/blog\/2019\/02\/07\/swift-abi-stability-and-more\/\">Swift ABI Stability and More<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Ben Cohen: One of Swift&rsquo;s goals is to be a good language for libraries with binary compatibility concerns, such as those shipped as part of Apple&rsquo;s OSs. This includes giving library authors the flexibility to add to their public interface, and to change implementation details, without breaking binary compatibility. At the same time, it&rsquo;s important [&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":"2019-04-15T21:03:12Z","apple_news_api_id":"4b56e6c8-3f44-4015-b127-17e5983f2966","apple_news_api_modified_at":"2019-04-15T21:03:13Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AS1bmyD9EQBWxJxflmD8pZg","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":[31,46,30,71,901],"class_list":["post-25000","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-ios","tag-languagedesign","tag-mac","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25000","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=25000"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25000\/revisions"}],"predecessor-version":[{"id":25001,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25000\/revisions\/25001"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=25000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=25000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=25000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}