{"id":1412,"date":"2008-11-30T15:26:04","date_gmt":"2008-11-30T19:26:04","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/?p=1412"},"modified":"2008-11-30T15:26:04","modified_gmt":"2008-11-30T19:26:04","slug":"readability","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2008\/11\/30\/readability\/","title":{"rendered":"Readability"},"content":{"rendered":"<p>I&#8217;m not exactly the model programmer, but I&#8217;m a big nut on readable code.<\/p>\n<p>I&#8217;ve been doing a lot of PHP, but now I&#8217;m starting to get back into Perl. And I&#8217;m realizing that, in Perl, it&#8217;s <em>very<\/em> easy to write code that makes absolutely no sense to anyone except the most seasoned veterans. It does a lot of what I occasionally chastize myself for doing: taking bizarre shortcuts that shave a few seconds off of writing the code, have no impact on performance, but make your code fairly hard to interpret.<\/p>\n<p>I was trying to figure out how readline() works, for example (I shouldn&#8217;t have to look that one up), and they gave this example code block:<\/p>\n<pre>\n    for (;;) {\n        undef $!;\n        unless (defined( $line = <> )) {\n            die $! if $!;\n            last; # reached EOF\n        }\n        # ...\n    }\n<\/pre>\n<p>The very first line is odd: a for loop with no parameters. It&#8217;s easy enough to assume that it&#8217;s to do an infinite loop. The next line ensures that $! is undefined, $! being a variable pointing to errors. (Obviously. What else could $! mean?) The $line = <> is probably clear to anyone who knows Perl, though it&#8217;s certainly not intuitive as explicitly stating that it&#8217;s referring to STDIN. I find the unless() syntax to be nifty: it&#8217;s the same as if(!(&#8230;)), but a little clearer. Except I only find it intuitive if it&#8217;s expected that the evaluation will be true: unless a rare event happens&#8230; Here, it&#8217;s unless reading from STDIN is defined. <\/p>\n<p>And even the die() bothers me: maybe there&#8217;s no sense in writing out an if($!) { die $! }, but I would have. <\/p>\n<p>All around, I feel as if everything in Perl relies on very terse, bizarre naming schemes, and have always thought that a lot of Perl programmers take pride in writing the most obfuscated code imaginable. There are a lot of languages that I can &#8220;read&#8221; pretty well: I can sit down and look at your code and figure out what it does. But Perl isn&#8217;t one of them. Case in point: I&#8217;m scratching my head trying to make readline() read a line of data at a time. That&#8217;s what it&#8217;s supposed to do, but that&#8217;s not what it&#8217;s doing. Another time, a function returned an array full of <i>references<\/i>, a fact that was buried somewhat obscure in the documentation. Don&#8217;t get me wrong: it&#8217;s a very powerful language, and some brilliant people have done some amazing stuff with it. But it doesn&#8217;t have the same beginner-friendliness that other languages do. The same could be said, I suppose, for vi or Linux. But  I have lots of reasons why I think Linux and vi are much better than the alternatives. I don&#8217;t have any reason to think that Perl is any better than its numerous alternatives. (PHP, Ruby, Python, bash&#8230;)<\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m not exactly the model programmer, but I&#8217;m a big nut on readable code. I&#8217;ve been doing a lot of PHP, but now I&#8217;m starting to get back into Perl. And I&#8217;m realizing that, in Perl, it&#8217;s very easy to &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2008\/11\/30\/readability\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1412","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/1412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=1412"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/1412\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=1412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=1412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=1412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}