Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^17: eval to replace die?

by BrowserUk (Pope)
on Oct 09, 2010 at 14:14 UTC ( #864384=note: print w/ replies, xml ) Need Help??


in reply to Re^16: eval to replace die?
in thread eval to replace die?

"=~ is more volatile than eq/ne" is flawed?

Yes. It takes only a one character typo or transposition to screw either up. And once tested, both are proven until something changes. When something changes, both need to be re-tested. Regex may be harder to get right, but once they are tested as correct, they don't suddenly start randomly acting differently. If they matched today, they will match tomorrow, unless something else changes. And when something else changes, it is just as likely to screw up eq as =~.

That is a complete, dispassionate, rational evaluation. It is also incontrovertible.

i am of the belief that your hate of another language...

The language in question I think has done the industry I've loved being a part of for the last 30 years, a considerable disservice.

Java probably has no more bad programmers as a percentage, than any other language, but because they are a) more numerous than most other languages; and b) the consequent high demand for them, means that forces of natural selection that usually weed out the worst, hasn't operated as it normally would; combined with c) the artificial "legitimacy" that somehow arose around it; means that companies around the world have tried to reduce the art of programming--and programmers--to a commodity items.

Instead of employing a number of higher paid, higher skilled programmers and analysts (and project managers), they started trying to throw large numbers of low-paid, less skilled people at projects. Java enables that because it effectively reduces all language development to a single construct: object.action( args );. This is very easy to teach, and so you can push large numbers of people through certification processes very quickly. But along the way it produced a whole generation of programmers that know only one way to everything. They have no exposure to procedural, funtional or any other style of programming than OO. And that's a monoculture. And monocultures are always bad.

The result is that each individual developer, analyst or architect concentrates upon one tiny part of an overall project with no one person having a full overview. And the bloated, discordant, memory and cpu hungry results of that have become manifest.

I like OO. I use OO (when appropriate). I'm even quite good at OO. So your attempts to label me an "OO hater" cut no ice. I'm just sufficiently experienced to know that there are other ways of doing things; and for many problems they are better.

also your hate of one specific person.

It is a matter of personal ethics that I don't "hate" anyone. Much less people I have never met, nor even had a one-on-one conversation with.

Read my sig. I argue the the issues; never the person. But you cannot argue the issues effectively without talking to their main proponents. Trying to take my arguments against a person's stated position; as any kind of emotional attack on that person, is the last refuge of the desperate.

I love the Perl language. And I take issue with anyone I perceive to be advocating the "dumbing down" and commoditasation of Perl. I do so, because I believe that it is detrimental to Perl in the wider context. But I have nothing to gain from my efforts except, perhaps, whatever long term effects my dispassionately logical arguments might have upon individual members of the Perl community. Or not.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^17: eval to replace die?
Download Code
Re^18: eval to replace die?
by mithaldu (Monk) on Oct 09, 2010 at 16:02 UTC
    Just a simple real life example, derived from my day to day work:

    An application that deals with item prices delivered by third party servers (so, unknown ahead of time) and does a change check before each action that has to do with actual cash. If the price changes, it backs out and tells the user, with the message highlighted in red or green. Prices are displayed in full euro values at all times for brevity.

    With exceptions:
    die { type => 'PriceChange', amount => -123 };
    The exception handler can recognize it by eq'ing the type and derive the direction from doing a numerical inspection of the amount and then shunt the whole thing through a template generator.

    With strings:
    die "PriceChange: The price changed by -123 Euro.";
    The exception handler does:
    $error =~ m/^(\w+)\:.* ([-\d]+) /; if ( $1 eq 'PriceChange' ) { my $direction = determine_direction( $2 ); return price_change_error( $error, $direction ); } else { return "UNKNOWN ERROR!"; }

    Both work fine. Now management decides: "We want the decimals displayed!"

    So the die errors get changed:

    die { type => 'PriceChange', amount => -123.45 };
    die "PriceChange: The price changed by -123.45 Euro.";


    You see what happens, right? And just in case you try to argue "this code is dumb", yes it is. But let me assure you it's tame against the shit i've seen in production over the years.


    And lastly, i'm not going to try and address your wall of text at the bottom there. I dislike Java as well, i dislike OO as well and only use it when i can't think of a lispy way to do something. But i never labeled you as an OO-hater, you made that up on your own. I merely said that i think you're too busy hating Java to allow yourself to see that E::C has little to do with it at the core.
      You see what happens, right?

      Yes. You've made a change to the program, so you run it through your test suite. ( You do have one don't you?)

      You discover the problem and you correct it. End of.

      But let me assure you it's tame against the shit I've seen in production over the years.

      Then fix your process.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        With an exception that is a structure there is no need to correct any problem. The test suite still passes because there is no problem.

        Which was the whole point of this entire debate: It is much easier to run into trouble by using string-only errors.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-11-28 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (191 votes), past polls