At 2003-06-13T01:13:05Z, Steve Lamb <[EMAIL PROTECTED]> writes: > Uh, no, read my post where I said that for any given situation I prefer > Perl over Shell script.
OK, I hadn't seen that. > I also happen to have worked with Perl for far too long to fall into the > trap that it is easily maintainable or easy to write "clean" code. I think we'll have to agree to disagree. > Took me all of 2 minutes to find idiomatic code. > > unless (defined ($evblock{$opt{'alias'}})) > { > exitWithError("Alias \"$opt{'alias'}\" is not configured."); > } > > > We'll forgive the fact you have no consistant way to set way to use parens > (sometimes you use them, sometimes you don't, someitmes when you do you > have spaces between the parens and the caller, sometimes you don't) I'll admit that I'm not 100% consistent about that. I tend to use parens when it helps to disambiguate the meaning of the code, along the lines of saying "2 * 2 + 3" or explicitly stating "3 + (2 * 2)", even though the statements are exactly equivalent without the parens. > this right here is the prime example of idiomatic Perl that causes > problems. I never use unless. Why? First off every other language does if > not, not unless. True, but I forget the subtle differences between "not" and "!", so I tend to avoid using them. > Secondly you cannot else an unless. Yes, you can. I just tried this: #!/usr/bin/perl -w use strict; unless (1) { print "False\n"; } else { print "True\n"; } and it runs without error and prints the correct answer. > My opinions, however, I can back up with examples from your own code. I note that you pointed out my inconsistency, but not any unreadability. :) > Examples which I can explain why the code is inconsistant and hard to read > yet, in Perl, it is considered correct, accurate and "good". You used an > idiom without even knowing it and profressed to not use idiomatic Perl! I think of "idiomatic Perl" as constructs like: foreach $_ ($switch) { /^a$/ and do { print "a"; }; /^b$/ and do { print "b"; }; /^c$/ and do { print "c"; }; } instead of the more C-like: if ($switch eq 'a') { print "a"; } elsif ($switch eq 'b') { print "b"; } elsif ($switch eq 'c') { print "c"; } A C programmer can figure out the second stanza, but the first will probably make him cuss at me. > I agree. I think shell is difficult to maintain because of the overly > complex rules on parameter passing. At least when I unlink($foo) I don't > have to worry if $foo is '/ -rf' and be paranoid about it as I do in shell > script. Have you ever looked at the source for Big Brother? It may've changed, but it used to be written in Bash and C. We tried to avoid any customizations that weren't 100% necessary at all costs. > However, having said that I also prefer Python over Perl for the simple > fact that it is far more readable than Perl and you don't have the > multiple correct ways to do something Perl has. I have no strong preference, but I was extremely happy when I wrote my first GUI program, ever, without any automatic code generator or template builder, with Emacs in Python in the two days following the arrival of "Programming Python". That is, I had never written a line of Python before receiving that book, and I had never written a single GUI program in my life. My first Python program was a GUI wrapper for Amanda backup software, involving dynamically-updating textboxes and using SSH and sudo to launch programs on remote machines. I have to say that I liked it. > Furthermore I have written multi-threaded test scripts without commens > that did the same thing as our in-house Perl scripts had people who > neither wrote Perl or Python come over and tell me in 30s what it did. > That, sir, is readable. I agree 100% that if you understand general programming concepts, you can read Python. I still say that I go to lengths to make my Perl readable by others. I've received emails from people who use Antonym who were happy about how easy it was to understand and modify, even if they weren't Perl programmers. -- Kirk Strauser In Googlis non est, ergo non est.
pgp00000.pgp
Description: PGP signature