Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Perl is dying (hyperbole)

by Aristotle (Chancellor)
on Jul 16, 2006 at 08:10 UTC ( #561525=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl is dying
in thread Perl is dying

The ST is suboptimal among several axes. Its only real advantage is that itís a single expression. I donít know why people insist on using it in places where thatís of no benefit.

And no, none of the alternatives I use involve modules. Next time, try to argue without putting up a strawman and then adding a slippery slope to it.

Makeshifts last the longest.


Comment on Re^2: Perl is dying (hyperbole)
Re^3: Perl is dying
by Jenda (Abbot) on Jul 16, 2006 at 08:15 UTC

      Generally I use an extra array for extracted keys and then use it to sort indices.

      my @sorted = do { my @key = map { lc substr $_->[ 4 ], 0, 3 } @a_of_a; my @idx = sort { $key[ $a ] cmp $key[ $b ] } 0 .. $#key; @a_of_a[ @idx ]; };

      Thatís much easier to follow than the ST. Additionally, it uses orders of magnitude less memory for large datasets because it doesnít create zillions of tiny anonymous arrays. (I love Perlís effortless data structures and what they enable, I really do, but roughly 100 bytes of overhead for an empty arrayÖ talk about wasteful.) Itís also faster for the same reason. In fact, itís a speed demon Ė as fast as it gets without a GRT, or possibly faster if the transform you need for your GRT is costly.

      Whatís not to like? I see very little reason to use a classic ST.

      Makeshifts last the longest.

        In another node, you mention this came from APL. I comment here since this is the prettier version than in Re: An APL trick for the Schwartzian Transform.

        Googling this has become Hard (not NP hard). Know of any off hand references?

        I'm wondering if being concerned about the 100 byte overhead is a form of premature optimisation. Hypothetically perl should be able to determine if the arrays are going to have their size changed, or the arrays will be preserved or whatever, and if possible use a something more efficient.

        Actually here is where Perl5 could steal a trick from Python and add a Tuple data type, that is an array like data type that is of constant size and contains constant values. Having such a data type would make it possible to write ST's and be MUCH more efficient, since the constantness of the structure would allow the structure to be represented in a much more efficient way. Much of the size issues of perls data structures are due to its dynamic nature, and the fact that we optimise for speed and not space.

        ---
        $world=~s/war/peace/g

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-07-22 20:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (127 votes), past polls