http://www.perlmonks.org?node_id=1030293


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

Replies are listed 'Best First'.
Re^3: List::Utils can't find max in array of BigInts (XS--)
by tye (Sage) 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        

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.