{"id":10265,"date":"2014-12-09T00:23:51","date_gmt":"2014-12-09T05:23:51","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10265"},"modified":"2021-05-28T21:01:22","modified_gmt":"2021-05-29T01:01:22","slug":"rewriting-robotics-software-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/12\/09\/rewriting-robotics-software-in-swift\/","title":{"rendered":"Rewriting Robotics Software in Swift"},"content":{"rendered":"<p><a href=\"http:\/\/www.sunsetlakesoftware.com\/2014\/12\/02\/why-were-rewriting-our-robotics-software-swift\">Brad Larson<\/a> (via <a href=\"https:\/\/twitter.com\/siracusa\/status\/542143252812795904\">John Siracusa<\/a>):<\/p>\n<blockquote cite=\"http:\/\/www.sunsetlakesoftware.com\/2014\/12\/02\/why-were-rewriting-our-robotics-software-swift\"><p>At SonoPlot, we just undertook a full rewrite of our robotic control software from Objective-C to Swift. While at first it might appear crazy to rework a large, stable project in a brand-new language, we did so after carefully examining sources of bugs in our Objective-C application and determining that Swift would prevent a large percentage of them.<\/p>\n<p>[&#8230;]<\/p>\n<p>I found myself repeatedly saying to myself or Janie that a particular bug wouldn&rsquo;t have even compiled under Swift, or would have thrown an immediate exception. When we totaled up bugs like this, we found that <a href=\"https:\/\/twitter.com\/bradlarson\/status\/518053543866269696\" rel=\"nofollow\">~40% of bugs shipped to customers in the last three years would have been caught immediately by using Swift<\/a>. The primary classes of these bugs were:<\/p>\n<ul>\n<li>Silent failures due to nil-messaging<\/li>\n<li>Improperly handled NSErrors, or other Objective-C error failures<\/li>\n<li>Bad object typecasts<\/li>\n<li>Wrong enum lookup tables being used for values<\/li>\n<\/ul>\n<\/blockquote>\n<p>This is a great exercise, and of course I like that Swift makes these types of bugs impossible. On the other hand, although I certainly write my share of bugs, I can&rsquo;t remember the last time one fell into one of these categories. I haven&rsquo;t counted, but my guess is that it&rsquo;s less than 1%.<\/p>","protected":false},"excerpt":{"rendered":"<p>Brad Larson (via John Siracusa): At SonoPlot, we just undertook a full rewrite of our robotic control software from Objective-C to Swift. While at first it might appear crazy to rework a large, stable project in a brand-new language, we did so after carefully examining sources of bugs in our Objective-C application and determining that [&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":"2021-05-29T01:01:26Z","apple_news_api_id":"fecbfb13-9a85-42f3-b7a2-fbfecb0f1cd1","apple_news_api_modified_at":"2021-05-29T01:01:26Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A_sv7E5qFQvO3ovv-yw8c0Q","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,30,857,54,71,2074,901],"class_list":["post-10265","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-mac","tag-nserror","tag-objective-c","tag-programming","tag-software-rewrite","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10265","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=10265"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10265\/revisions"}],"predecessor-version":[{"id":10266,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10265\/revisions\/10266"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}