Welcome to the Monastery | |
PerlMonks |
Re: Is there a difference in this declaration?by wjw (Priest) |
on May 13, 2014 at 10:49 UTC ( [id://1085884]=note: print w/replies, xml ) | Need Help?? |
I think the answer to your question is dependent on context: Correctness usually is ... If your writing a program that is likely to run for hours on an expensive resource, then perhaps the interesting bench-marking discussed by other posters probably counts for something. After all: if it is costing lots of $$/minute to run the program, it might be worth it to spend the $$ up front and have really efficient code from a hardware performance and resource point of view.(But if that were the case, would you be programming in Perl?) If your writing code under the vast majority of circumstances, then the 'team' aspect is probably more important, as wading through code written for brevity, as compared to having been written for readability/maintainabilty, can be costly. Personally, I prefer code which, when read by someone other than the author, does not assume that the reader knows much about the implicit characteristics of how the code compiles or runs. It boils down to a potential trade-off between some extra hardware resources applied occasionally as compared to wetware resources applied fairly regularly. On the other hand, that does not mean that every line needs a comment either as some level of skill should be assumed to be had by the code reader/modifier. Obviously a balancing act... In my experience, correctness is the in realm of those that think the world should reflect the way they like things to be, as compared to for example, the way I like things to be. :-) Am I correct or are they? I am of course! The point is that if you take a look around at code written by others who appear to be better than you are and find someone whose code you like, emulate that until you have a valid reason not to. If your goal is to be correct, you are going to spend an awful lot of time defending your version of correct. Do what works for you and does not get in the way of others and you will be about as correct as your likely to ever be... Incidentally, I like the 'my %hash = ();' just because it is so explicit. Am I correct? I doubt it...but it works for me and most others really don't give a damn that I spent and extra 5 keystrokes.... :-)
...the majority is always wrong, and always the last to know about it... Insanity: Doing the same thing over and over again and expecting different results...
In Section
Seekers of Perl Wisdom
|
|