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

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.

Replies are listed 'Best First'.
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.

        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.


        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?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://561525]
[Tux]: choroba++ # pm_cb_g also signals replies to posts, something#cbstream does not
[marto]: good afternoon all
[marto]: that is a neat feature, I'll have to have a look at how it displays that

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2017-09-22 12:30 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (262 votes). Check out past polls.