{"id":16598,"date":"2016-12-12T15:21:45","date_gmt":"2016-12-12T20:21:45","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=16598"},"modified":"2018-01-12T10:23:55","modified_gmt":"2018-01-12T15:23:55","slug":"insanity-template-based-code-generation-for-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/12\/12\/insanity-template-based-code-generation-for-swift\/","title":{"rendered":"Sourcery: Template-Based Code Generation for Swift"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/krzysztofzablocki\/Insanity\">Krzysztof Zab&#322;ocki<\/a> (<a href=\"https:\/\/twitter.com\/merowing_\/status\/808021138915950592\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/github.com\/krzysztofzablocki\/Insanity\"><p>Swift is a beautiful language that powers a lot of great iOS apps. Unfortunately it features very limited runtime and no meta-programming features. This has led our projects to contain a lot of duplicated code patterns, they can be considered the same code, just with minimal variations.<\/p>\n<p>[&#8230;]<\/p>\n<p>Insanity is a tool that scans your source code, applies your personal templates and generates Swift code for you, allowing you to use meta-programming techniques to save time and decrease potential mistakes.<\/p><\/blockquote>\n<p><a href=\"https:\/\/twitter.com\/khanlou\/status\/808031395163598848\">Soroush Khanlou<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/khanlou\/status\/808031395163598848\"><p>Codegen is gonna become a crucial part of Swift development in not very long.<\/p><\/blockquote>\n<p>Update (2016-12-12): <a href=\"https:\/\/twitter.com\/pilky\/status\/808411863683923968\">Martin Pilkington<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/pilky\/status\/808411863683923968\"><p>I can&rsquo;t help but feel that code generation is a code smell. Shows a language\/API weakness.<\/p><\/blockquote>\n<p>Update (2016-12-13): <a href=\"https:\/\/twitter.com\/merowing_\/status\/808558392163897344\">Krzysztof Zab&#322;ocki<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/merowing_\/status\/808558392163897344\">\n<p>Insanity has been renamed to Sourcery, and we just released 0.3.0 version, old links \/ remotes should work fine.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Krzysztof Zab&#322;ocki (tweet): Swift is a beautiful language that powers a lot of great iOS apps. Unfortunately it features very limited runtime and no meta-programming features. This has led our projects to contain a lot of duplicated code patterns, they can be considered the same code, just with minimal variations. [&#8230;] Insanity is a tool [&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":[888,941,74,71,901],"class_list":["post-16598","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-code-generation","tag-macros","tag-opensource","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/16598","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=16598"}],"version-history":[{"count":4,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/16598\/revisions"}],"predecessor-version":[{"id":20147,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/16598\/revisions\/20147"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=16598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=16598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=16598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}