Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Is there a difference in this declaration?

by wjw (Priest)
on May 13, 2014 at 10:49 UTC ( #1085884=note: print w/replies, xml ) Need Help??


in reply to Is there a difference in this declaration?

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...
  • Comment on Re: Is there a difference in this declaration?

Replies are listed 'Best First'.
Re^2: Is there a difference in this declaration?
by DrHyde (Prior) on May 14, 2014 at 10:45 UTC

    As we speak I have a script running which is consuming *two* expensive resources - CPU and disk I/O. It started running on April the 21st. It is now the 14th of May and I expect it to finish in the wee small hours of the 15th. It even spends a lot of that time in some tight loops, as it is producing summaries of a very large data-set.

    However, "optimizations" like worrying about whether I initialize my variables are foolish. I have loads of far better optimizations. For example, my script runs exactly as parallel as is most efficient, all the time. This means that it uses all the CPU cores available while minimizing conflicts over resources.

    If I care to optimize it further I will minimize disk I/O. But the time taken for disk I/O is only about 20% of the time taken by the process, so we're already getting into the stage where the amount of time it would take to optimize the code or the money it would take to invest in more memory (so less use of disk for intermediate results) or an SSD (just as much disk I/O but contention matters less) isn't really worth it.

      Thanks for that! It validates most of what I thought and answers the question: (would it be written in Perl?).

      Clearly it would and is.

      I have to imagine it must be pretty satisfying to come to work each day and see that code chunking away!

      Again, thanks!

      ...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...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1085884]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2019-07-19 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?