So I'm reading some Perl code. I usually stay away from Perl as much as I can, but I'm trying to figure out some undocumented behavior of the MusicBrainz RDF server so I have to UTSL. Anyway, I get to this line:
      return ("No artist name or artist id given.", $data, 0, undef) 
and I get confused, because I saw the artist ID check but not the artist name check. So I start reading backwards to see if I missed something; maybe the artist name check happened in some non-obvious function call? I go skimming through various other files to see if some other code is filling in the artist ID or something. Eventually, I give up and come back to that line, and I notice that the next line is:
          if ($data->{artist} eq '');
and I smack my head. I'm willing to chalk this up to bad style (and I hope people would agree this is bad style), but now I'm wondering: when is it ever good style to put the conditional guard after the code it's guarding? Or, more generally, when is it ever good style for the order of code (in the same basic block) to be the opposite of the order of execution?

From: [identity profile] mshonle.livejournal.com


Can you give me the gist of it? Hopefully it's more than just "hackers get things done, instead of painters who make beautiful things that are useless." I've already granted that Perl and Python are useful; it's just that there are so many missed opportunities in both languages that it's a tremendous pitty.

Anyway, it's just a fact that sometimes the trivial dominates over the fundamental. I used to be the same way until I studied programming languages at Northeastern under Mitch Wand, Matthias Felliesen, and Karl Leiberherr.

From: [identity profile] dougo.livejournal.com


It's written by Paul Graham, so I think he's on our side. For example, in a talk he gave at Northeastern:
If I could get people to remember just one quote about programming, it would be the one at the beginning of Structure and Interpretation of Computer Programs.
Programs should be written for people to read, and only incidentally for machines to execute.

From: [identity profile] bitjuggler.livejournal.com

Exactly...


syntax is for people, so denigrating language designers who focus on syntax and 'dumb, experimental ideas of little importance' seems to me to be denigrating what I see as the main object of language design: to make programs easy to understand for both the writer and future readers (and incidentally for the machine itself).
.

Most Popular Tags

Powered by Dreamwidth Studios

Style Credit

Expand Cut Tags

No cut tags