{"id":9972,"date":"2014-10-22T13:36:12","date_gmt":"2014-10-22T17:36:12","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=9972"},"modified":"2014-10-22T13:36:12","modified_gmt":"2014-10-22T17:36:12","slug":"lebeaupin-on-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/10\/22\/lebeaupin-on-swift\/","title":{"rendered":"Lebeaupin on Swift"},"content":{"rendered":"<p><a href=\"http:\/\/wanderingcoder.net\/2014\/10\/21\/swift-thoughts\/\">Pierre Lebeaupin<\/a>:<\/p>\n<blockquote cite=\"http:\/\/wanderingcoder.net\/2014\/10\/21\/swift-thoughts\/\">\n<p>Nested block comments do not work. They cannot be made to work (for those who care, I filed this as rdar:\/\/problem\/18138958\/, <a href=\"http:\/\/www.openradar.me\/18138958\">visible on Open Radar<\/a>; it was closed with status &ldquo;Behaves correctly&rdquo;). That is why the inside of an <code>#if 0<\/code> \/ <code>#endif<\/code> pair in C must still be composed of valid preprocessing tokens.<\/p>\n<p>[&#8230;]<\/p>\n<p>Little did I know that not only Swift method calls are not more dynamic than Objective-C method calls, but in fact don&rsquo;t use <code>objc_msgSend()<\/code> at all by default! Look, <code>objc_msgSend()<\/code> (and friends) is the whole point of the Objective-C runtime. Period. Everything else is bookkeeping in support of <code>objc_msgSend()<\/code>. [&#8230;] Apple is trying to convince us of the Objective-C-minus-the-C-part lineage of Swift, but the truth is that Swift has very little to do with that, and much more to do, semantically, with C++. This would never have happened had Avie Tevanian still been <s>alive<\/s> working at Apple.<\/p>\n<p>[&#8230;]<\/p>\n<p>I find it very odd that there is no description or documentation of threading in Swift. And yes, I know you can spawn threads using the Objective-C APIs and then try and run Swift code inside that thread; that&rsquo;s not the point. The point is: as soon as I share any object between two threads running Swift code, what happens?<\/p>\n<p>[&#8230;]<\/p>\n<p>I don&rsquo;t like: the lacks of a narrative, or at least of a progression, in the book. Where is the rationale for some of the less obvious features? Where is the equivalent of Object-Oriented Programming with Objective-C (formerly the first half of &ldquo;Object-Oriented Programming and the Objective-C Programming Language&rdquo;)? This matters, we can&rsquo;t just expect to give developers a bunch of tools and expect them to figure out which tool is for which purpose, or at least not in a consistent way. Providing a rationale for the features is part of a programming language as well.<\/p>\n<p>[&#8230;]<\/p>\n<p>Swift seems to go counter to all historical programming language trends: it is statically typed when most of the language work seems to trend towards more loosely typed semantics and even duck typing, it compiles down to machine code and has a design optimized for that purpose when most new languages these days run in virtual machines, it goes for total safety when most new languages have abandoned it. I wonder if Swift won&rsquo;t end up in the wrong side of history eventually.<\/p>\n<p>[&#8230;]<\/p>\n<p>Swift, with its type safety, safe semantics and the possibility to tie variables as part of control flow constructs (<code>if let<\/code>, etc.), promises to capture programmer intent better than any language that I know of, which ought to ease maintenance and merge operations; this should also help observability, at least in principle (I haven&rsquo;t investigated Swift&rsquo;s support for DTrace), and might eventually lead to an old dream of mine: formally defined semantics for the language, which would allow writing proofs (that the compiler could verify) that for instance the code I just wrote could not possibly crash.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Pierre Lebeaupin: Nested block comments do not work. They cannot be made to work (for those who care, I filed this as rdar:\/\/problem\/18138958\/, visible on Open Radar; it was closed with status &ldquo;Behaves correctly&rdquo;). That is why the inside of an #if 0 \/ #endif pair in C must still be composed of valid preprocessing [&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":[800,46,966,54,71,901],"class_list":["post-9972","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-concurrency","tag-languagedesign","tag-message-passing","tag-objective-c","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9972","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=9972"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9972\/revisions"}],"predecessor-version":[{"id":9973,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9972\/revisions\/9973"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=9972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=9972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=9972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}