A question of Style, was: SPUG: Sort an array question

Geoffrey & Kristin Grosenbach glyph at mac.com
Sun Dec 29 14:16:13 CST 2002


This is a fascinating benchmark...I had a co-worker tell me that the 
c-style loop was faster because Perl didn't have to keep track of the 
array on it's own, but he didn't have any code to back it up. I'll have 
to show him this one.

And since we're sort of on this topic, does anyone have any 
recommendations for convincing co-workers that writing readable code is 
actually better for the company's bottom line?
    I can enforce coding standards for the coders I manage, but I had a 
conversation last week with another who said "It only takes me an extra 
one or two hours a week to maintain our current [obfuscated] codebase, 
and a rewrite wouldn't gain us any more than one or two hours a week, so 
it's not really worth it financially."



On Saturday, December 28, 2002, at 05:36  PM, Jeremy Mates wrote:

> * Michael R. Wolf <MichaelRunningWolf at att.net> [2002-12-28T16:31-0800]:
>> my personal preference would be to go with the 3-part for
>>
>> 	for (my $i = 0; $i < @array; $i++) {
>> 	    for (my $j = $i+1; $j < @array; $j++) {
>>
>> since it's such a well-known idiom.
>
> More readable for the C folks, but about 60% slower than using the
> .. loop syntax.
>
> http://www.sial.org/code/perl/bench/for-loops.pl
>
> --
> Jeremy Mates                                        http://www.sial.org/
>
> OpenPGP: 0x11C3D628  (4357 1D47 FF78 24BB 0FBF 7AA8 A846 9F86 11C3 D628)
>
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
> - -
>      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL by your 
> Email-address
>  For daily traffic, use spug-list for LIST ;  for weekly, 
> spug-list-digest
>      Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
>
>


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list