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

Re: Re (tilly) 1: cat vs. file handle speed?

by Adam (Vicar)
on Mar 30, 2001 at 06:08 UTC ( #68264=note: print w/ replies, xml ) Need Help??


in reply to Re (tilly) 1: cat vs. file handle speed?
in thread cat vs. file handle speed?

I think exceptions can be made for pseudo-code Tilly. Focus on the question.

Update
Tilly says, "I find that what people do in pseudo-code, they do in real code as well. Error checks should be a reflex."
I completly disagree. Since I never use open without an or die, I never bother with it in pseudo-code. pseudo-code is specifically for reducing the algorithm to its core piece. Your later argument that two of the methods lost $! is a good one, but your argument that the examples presented contain no error checking is irrelevant. More to the point, your initial statement, "2/3 of these are syntax errors," is also out of place and inappropriate. You took an honest question and made two pointless statements as an attempt to say, "dorpus, you are asking the wrong question." I worry about that kind of response as it does nothing to assist our fellow monks and undermines your own credability as one of our more learned and informed monks. I've enjoyed our discussions here, and I think you have much to contribute. But your response here was wrong and I have no qualms about pointing that out.


Comment on Re: Re (tilly) 1: cat vs. file handle speed?
Re (tilly) 3: cat vs. file handle speed?
by tilly (Archbishop) on Mar 30, 2001 at 22:58 UTC
    I suspect that we will disagree on this then. My point was that if you are at a point where you do not - by reflex - get the syntax right and put the error checks in, then the optimization question is not where you need to concentrate. And, of course, if you do try to fix those items then you should quickly discover my real point, which is that error reporting with 2 of the solutions is made much harder. That fact is one of the key reasons why it is a bad idea to write Perl as a glorified shell.

    As for whether $! was a later argument, well I don't think so. You see I am in the habit of giving answers where you are unlikely to see the point of the answer unless you try it. If you try it you will discover that for yourself, and I believe that makes it stick better. If you do not try it, well my typing it wouldn't have helped because you would have just forgotten that as well.

    So yes, I was attempting to make it clear that dorpus was asking the wrong question. That was not an accident, that was the point. And I think that what I said does help our fellow monks. Why? Because it tells them what I think is important. I believe that if they value what I think is important here, that will be helpful. It may not be the help that was requested, but I am (in case you had not noticed) someone who tries to give the help that I think does the most good, even if it is not the help that was asked for.

    Furthermore when I first answered I gave concious thought to the question of whether I should answer the question as posed. You see I knew from the start that any of the three could beat the other two in practice. I sincerely thought about saying that up front, but I decided that it would obscure the critical point.

    And the critical point is that 99.9% of the time this is the wrong question to ask. The remaining 0.1% of the time, if you ask it and think carefully, you will come to the same answer that you would have come to if you had asked the right question in the first place. Therefore I thought it justified to only say what I considered to be key. Which is that until you reflexively get the syntax right and reach for the error check, it is more important to focus on those things than worrying about raw performance.

    Now if this undermines my credibility, then so be it.

    And continuing on, you may be different, but I used to claim that I never opened without a die in real code. But first I realized that if I showed my pseudo-code to others I wanted to put the die in so that they would not accidentally copy that. Then one day I caught myself missing that detail converting my own pseudo-code into production code. I then sat back, thought, and made the concious decision to always use it, even in pseudo-code, because I didn't want to accidentally pick up and use bad habits moving to production code.

    So YMMV, but what I do in pseudo-code I tend to do in production as well. So habits I want to have in my production code I try to stick to in pseudo-code.

      Ok. I can accept that. I think your point is better made, however, if you answer the question being asked first, and then explain the folly of their ways. It allows them to put the question to rest and focus on your statements, otherwise they are distracted by the fact that their question has still not been answered. But I can't force you to do that, nor would it be fair for me to try.

      As for the amount of details in pseudo-code, all I can say is to each his own, or as LW put it, TIMTOWTDI. It is the wrong place to critique a persons code, because it is not code. If they fail to check a syscall in actual code, then by all means have at them. But pseudo-code isn't code - which is what makes it useful.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-04-21 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (490 votes), past polls