{"id":41,"date":"2004-04-12T20:08:40","date_gmt":"2004-04-13T03:08:40","guid":{"rendered":"\/?p=41"},"modified":"2012-02-23T04:06:03","modified_gmt":"2012-02-23T12:06:03","slug":"programming-responsibility","status":"publish","type":"post","link":"https:\/\/www.slimjimmy.com\/weblog\/archives\/2004\/04\/12\/programming-responsibility\/","title":{"rendered":"Programming responsibility"},"content":{"rendered":"<p>I&#8217;ve recently spent some time looking at the source code to several open-source projects.<\/p>\n<p>I am appalled.<\/p>\n<p>Here&#8217;s a sampling of what I&#8217;ve encountered:<\/p>\n<ul class=\"expanded\">\n<li>\n\t\t<strong>Buffer overflows.<\/strong> I cannot understand how C programmers continue to use <code>gets<\/code>, <code>strcpy<\/code>, and <code>strcat<\/code> when <code>fgets<\/code>, <code>strncpy<\/code>, and <code>strncat<\/code> are available.  This isn&#8217;t that hard. (The C standard library shares a lot of blame; it never should have provided the unchecked versions, and it at least should have given <code>gets<\/code>\/<code>fgets<\/code> and <code>strcpy<\/code>\/<code>strncpy<\/code> consistent behaviors.  <code>strncpy<\/code> and <code>strncat<\/code> aren&#8217;t as easy to use as they ought to be, either.)\n\t<\/li>\n<li>\n\t\t<strong>Unchecked errors.<\/strong>  Writing error-checking code is hard and a lot of work, so apparently some people decide to forgo it altogether.  Woe upon the user.\n\t<\/li>\n<li>\n<p>\t\t<strong>Illegal language usage.<\/strong> Apparently a lot of people think it&#8217;s perfectly legal in C or C++ to name identifiers with a leading underscore.  Often it&#8217;s  not.  Although in practice a namespace clash is unlikely, <a href=\"http:\/\/groups.google.com\/groups?hl=en&amp;lr=&amp;ie=UTF-8&amp;oe=UTF-8&amp;selm=clcm-20011207-0001%40plethora.net\">identifiers with leading underscores can intrude into the compiler&#8217;s namespace<\/a>.<\/p>\n<p>\t\t<a href=\"http:\/\/www.codeproject.com\/tips\/stupidxortrick.asp\" class=\"unemphasized\">I&#8217;ve also argued<\/a> (unsuccessfully) with some people who recklessly invoke <a href=\"http:\/\/c-faq.com\/ansi\/undef.html\" class=\"unemphasized\">undefined behavior<\/a>.<\/p>\n<\/li>\n<li>\n\t\t<strong>Unmaintainable code.<\/strong> I suppose that I naively hoped that <a href=\"http:\/\/mindprod.com\/unmain.html\">How to Write Unmaintainable Code<\/a> was a work of fiction, but yes, Virginia, there are <a href=\"http:\/\/www.catb.org\/~esr\/jargon\/html\/M\/magic-number.html\" class=\"unemphasized\">magic numbers<\/a>.  It&#8217;s odd that so much open-source code has poor documentation, sparse comments, and cryptic function and variable names.  <strong>What&#8217;s the point of publishing your code if it&#8217;s unreadable?<\/strong>\n\t<\/li>\n<li>\n\t\t<strong>Inconsistent styles.<\/strong> More readability and maintenance problems stem from projects that lack strong core leadership.\n\t<\/li>\n<\/ul>\n<p>What&#8217;s the big deal?  The obvious problems are software vulnerabilities and broken software.  I think that there might be a deeper problem, however.<\/p>\n<p><strong>Code begets code.<\/strong> Many people learn how to program by looking through other people&#8217;s code, and publishing bad code makes it too easy to propagate bad habits and to produce lousy de facto standards.  Worse, people might copy-and-paste bad code outright.  Yes, it can work the other way too; good code can be a paradigm for others to follow.  Unfortunately, the sheer quantity of bad code available makes good code a needle in a haystack.  Saturating the planet with immature software projects is not a step forward.<\/p>\n<p>As potential pedagogues, open-source developers ought to be held to a higher standard.  Unfortunately, reality offers a contrary opinion.  A recent study indicates that <a href=\"http:\/\/news.com.com\/2030-1069_3-5187598.html\">email is more likely to be ignored when there are more recipients<\/a>; are similar factors at play in the programming world?  Does the nature of open-source code&#8212;where there&#8217;s a lack of accountability and where anyone can look at and change the source code&#8212;encourage its developers <strong>to shirk their responsibilities<\/strong> in the hopes that someone else will clean up their mess?  Or are programmers in general just too lazy, too unskilled, too ignorant, or too apathetic? (I&#8217;m admittedly not a very experienced programmer; I lack design experience in particular.  If nothing else, though, I&#8217;m meticulous (so Jeff Wong says) and consistent, and I make a conscious effort to be responsible with what I write!)<\/p>\n<p>(Before anyone gets the wrong idea, I am <em>not<\/em> an opponent of open-source software.  I&#8217;m picking on open-source code mostly because closed-source code isn&#8217;t available to be criticized.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve recently spent some time looking at the source code to several open-source projects. I am appalled. Here&#8217;s a sampling of what I&#8217;ve encountered: Buffer overflows. I cannot understand how C programmers continue to use gets, strcpy, and strcat when fgets, strncpy, and strncat are available. This isn&#8217;t that hard. (The C standard library shares [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,2],"tags":[],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-programming","category-rantsraves"],"_links":{"self":[{"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":0,"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.slimjimmy.com\/weblog\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}