{"id":11118,"date":"2013-04-24T09:15:58","date_gmt":"2013-04-24T16:15:58","guid":{"rendered":"http:\/\/www.preposterousuniverse.com\/blog\/?p=11118"},"modified":"2013-04-24T09:15:58","modified_gmt":"2013-04-24T16:15:58","slug":"why-is-code-hard-to-understand","status":"publish","type":"post","link":"https:\/\/preposterousuniverse.com\/blog\/2013\/04\/24\/why-is-code-hard-to-understand\/","title":{"rendered":"Why Is Code Hard to Understand?"},"content":{"rendered":"<p>Anyone who has tried to look at somebody else&#8217;s computer code &#8212; especially in the likely event that it hasn&#8217;t been well-commented &#8212; knows how hard it is to figure out what&#8217;s going on. (With sometimes <a href=\"http:\/\/en.wikipedia.org\/wiki\/MIM-104_Patriot#Failure_at_Dhahran\">dramatic<\/a> consequences.) There are probably numerous reasons why, having to do with the difference between heuristic human reasoning and the starkly literal nature of computer instructions. Here&#8217;s a short paper that highlights one reason in particular: people tend to misunderstand code when it seems like it <em>should<\/em> be doing one thing, while it&#8217;s actually doing something else. (Via Simon DeDeo.)<\/p>\n<blockquote><p><a href=\"http:\/\/arxiv.org\/abs\/1304.5257\">What Makes Code Hard to Understand?<\/a><br \/>\nMichael Hansen, Robert L. Goldstone, Andrew Lumsdaine<\/p>\n<p>What factors impact the comprehensibility of code? Previous research suggests that expectation-congruent programs should take less time to understand and be less prone to errors. We present an experiment in which participants with programming experience predict the exact output of ten small Python programs. We use subtle differences between program versions to demonstrate that seemingly insignificant notational changes can have profound effects on correctness and response times. Our results show that experience increases performance in most cases, but may hurt performance significantly when underlying assumptions about related code statements are violated.<\/p><\/blockquote>\n<p>As someone who is <a href=\"http:\/\/www.codecademy.com\/\">jumping back into programming<\/a> myself after a lengthy hiatus, this stuff is very interesting. I wonder how far we are away from natural-language programming, where we can just tell the computer what we want in English and it will reliably do it. (Guess: pretty far, but not <em>that<\/em> far.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Anyone who has tried to look at somebody else&#8217;s computer code &#8212; especially in the likely event that it hasn&#8217;t been well-commented &#8212; knows how hard it is to figure out what&#8217;s going on. (With sometimes dramatic consequences.) There are probably numerous reasons why, having to do with the difference between heuristic human reasoning and [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,27,34],"tags":[],"class_list":["post-11118","post","type-post","status-publish","format-standard","hentry","category-arxiv","category-religion","category-technology"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/posts\/11118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/comments?post=11118"}],"version-history":[{"count":2,"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/posts\/11118\/revisions"}],"predecessor-version":[{"id":11120,"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/posts\/11118\/revisions\/11120"}],"wp:attachment":[{"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/media?parent=11118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/categories?post=11118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/preposterousuniverse.com\/blog\/wp-json\/wp\/v2\/tags?post=11118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}