{"id":9912,"date":"2021-08-16T12:43:48","date_gmt":"2021-08-16T16:43:48","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=9912"},"modified":"2021-08-16T12:43:48","modified_gmt":"2021-08-16T16:43:48","slug":"in-defense-of-c","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=9912","title":{"rendered":"In Defense of C"},"content":{"rendered":"<p>I spent most of my career writing C code. I\u2019ve also got an old-timey and grumpy outlook so I\u2019m inclined to look on those disparaging C with a certain skepticism. Often, complaints about C are easy to dismiss as the uninformed mewlings from those who neither know nor write in C. But there are also complaints from knowledgeable programmers who have extensive experience in C.<\/p>\n<p>The complaints from those who know what they\u2019re talking about usually center around the issue of the \u201csafety\u201d of C and, in particular, its undefined behaviors. How can you write good code when there are so many undefined behaviors, when there\u2019s no bound checking for arrays, and all the other safety issues? It\u2019s a good question and seems compelling when you see it but, somehow, it always ran counter to my experience. Like every other programmer, I\u2019ve written lots of buggy code but none of it was because of undefined behaviors or because I busted an array bound. To me, the complaints of C being unsafe always seemed more theoretical than practical.<\/p>\n<p>I just came across a 2017 paper, <a href=\"https:\/\/www.humprog.org\/~stephen\/\/research\/papers\/kell17some-preprint.pdf\">Some Were Meant for C<\/a>, by Stephen Kell that examines the issue of C\u2019s safety and concludes that (1) the problems with C are not in the language itself but in its typical implementations and (2) that the features of C are essential for systems programming where \u201csystems programming\u201d is defined in a way that includes but is different from, say, kernel implementation.<\/p>\n<p>One of Kell\u2019s major points is that there\u2019s nothing in the C specification that prevents a safe implementation. Rather, he says, it\u2019s the erroneous belief that C users care mostly about performance that keeps compiler writers from adding, for example, bounds checking code. He also has a lot to say about the undefined behaviors and why they\u2019re necessary in a language like C.<\/p>\n<p>It\u2019s a fairly long paper but definitely worth reading if you\u2019re interested in C or confused about all the talk about its not being safe.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I spent most of my career writing C code. I\u2019ve also got an old-timey and grumpy outlook so I\u2019m inclined to look on those disparaging C with a certain skepticism. Often, complaints about C are easy to dismiss as the &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=9912\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[17,37],"class_list":["post-9912","post","type-post","status-publish","format-standard","hentry","category-general","tag-c","tag-tech"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9912"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9912\/revisions"}],"predecessor-version":[{"id":9913,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9912\/revisions\/9913"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}