Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: List::Utils can't find max in array of BigInts (XS--)

by salva (Abbot)
on Apr 24, 2013 at 07:32 UTC ( #1030293=note: print w/ replies, xml ) Need Help??


in reply to Re: List::Utils can't find max in array of BigInts (XS--)
in thread List::Utils can't find max in array of BigInts

But List::Utils does handle magic in the XS version too. The code is there to see... though it may be buggy.


Comment on Re^2: List::Utils can't find max in array of BigInts (XS--)
Re^3: List::Utils can't find max in array of BigInts (XS--)
by sundialsvc4 (Abbot) on Apr 24, 2013 at 12:31 UTC

    “It may be buggy” of course being the operative phrase here ...

    Sometimes pure-Perl brute force is just as good as anything else, because there’s only one way to find the maximum value in an unsorted list, and the overhead of the Perl interpreter running the loop to do that is probably worth ignoring.

Re^3: List::Utils can't find max in array of BigInts (XS--)
by tye (Cardinal) on Apr 24, 2013 at 15:01 UTC

    Having XS code that attempts to deal with even mundane Perl magic is still never something I expect. (Dealing with overloading wasn't something List::Util's XS code even attempted for the first decade of its existence). But, yes, XS code is indeed much, much more likely to be buggy than Perl code. Worse, XS code is much, much more likely to be buggy in ways that you don't notice at first and then cause your code to fail in ways that don't even hint that the XS code is to blame.

    But, you know: speed! It is vitally important that your max() function run a fraction of 1ms faster and increasing the code size by an order of magnitude and the code complexity by two orders of magnitude is surely worth all of the time wasted by everybody when it means that a few scripts are running a few ms faster and reducing their total run time by 0.2%.

    Every professional software developer knows that "trivially faster code" trumps "correct code" every time.

    Me, I tend to care a lot about hidden complexity of code. And so I'm pretty unlikely to use List::Util (especially since v1.23_03: "Dropped the pure-Perl implementation of both Scalar::- and List::Util."). I'll use Perl code because mundane Perl magic gets heavily tested and heavily exercised there and so the odds of me having to dive into the Perl source code because of a bug are much lower.

    - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-12-25 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls