{"id":73,"date":"2002-11-15T12:19:37","date_gmt":"2002-11-15T17:19:37","guid":{"rendered":"\/?p=73"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-30T04:00:00","slug":"leaky_abstractions","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2002\/11\/15\/leaky_abstractions\/","title":{"rendered":"Leaky Abstractions"},"content":{"rendered":"<p>Classy posts some <a href=\"http:\/\/www.classy.dk\/log\/archive\/000137.html\">thoughts<\/a> on Joel&rsquo;s <a href=\"http:\/\/www.joelonsoftware.com\/articles\/LeakyAbstractions.html\">Law of Leaky Abstractions<\/a>. I think Joel&rsquo;s basically right (that one should be careful about abstractions), but he frames his argument in a slightly misleading way.<\/p>\n\n\n\n<p>Here&rsquo;s how I look at it. An abstraction is an idea, like a specification. It can be good or bad for a particular purpose, but it can&rsquo;t fail. If the implementation doesn&rsquo;t conform to the abstraction it&rsquo;s supposed to, then the implementation is wrong. If the implementation conforms perfectly but doesn&rsquo;t have the desired effect, then you picked the wrong abstraction. Joel picks an easy target&mdash;optimistic abstractions that guarentee that everything is fast and nothing ever goes wrong&mdash;and then goes on to show that sometimes those are not the right abstractions to use. Well, duh.<\/p>\n\n\n\n<p>He then claims that the C++ string abstraction leaks:<\/p>\n\n\n\n<blockquote>C++ string classes are supposed to let you pretend that strings are first-class data. They try to abstract away the fact that strings are hard and let you act as if they were as easy as integers.<\/blockquote>\n\n\n\n<p>What&rsquo;s really going on here is that C++ does not define the abstraction that Joel wishes it did. The C++ implementation and specification do not conform to the string abstraction in his head. If you write your code assuming that strings are first-class you&rsquo;ll run into trouble, but that would be your fault&mdash;not the abstraction&rsquo;s.<\/p>\n\n\n\n<p>Joel&rsquo;s conclusion, &ldquo;The Law of Leaky Abstractions is dragging us down,&rdquo; is a tautology. It&rsquo;s like saying &ldquo;The bugs in our software are the reasons it doesn&rsquo;t work right.&rdquo;<\/p>","protected":false},"excerpt":{"rendered":"<p>Classy posts some thoughts on Joel&rsquo;s Law of Leaky Abstractions. I think Joel&rsquo;s basically right (that one should be careful about abstractions), but he frames his argument in a slightly misleading way. Here&rsquo;s how I look at it. An abstraction is an idea, like a specification. It can be good or bad for a particular [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"","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":[],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-programming-category"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/73","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}