It's actually a very old evil but maybe this means that people are starting to pay attention.
In related news, it's not too hard to quantify this penalty: fastOp=: 3 : '+/RND1-RND2' slowOp=: 3 : '%. RNDMAT' RND1=: 1e9-~100$@?2e9 [ RND2=: 1e9-~100$@?2e9 RNDMAT=: <:+:1000 1000?@$0 loopy=: 1 : 0 while. 0<:y=. <:y do. u 0 end. ) 6!:2 'fastOp"0]i.100' 0.00030730571 6!:2 'fastOp loopy 100' 0.00058112023 6!:2 'slowOp"0]i.100' 168.68835 6!:2 'slowOp loopy 100' 168.97309 NB. More precise exploration of the difference on a fast operation: tms=. ;6!:2 &.> (<'fastOp loopy '),&.>100$<'100' (<./,>./,mean,stddev) tms 0.00043795774 0.0004911783 0.00045778448 1.0047873e_5 tms0=. ;6!:2 &> (<'fastOp"0]'),&.>100$<'i.100' (<./,>./,mean,stddev) tms0 0.00025041998 0.0002902237 0.00025861169 6.8356761e_6 JVERSION Engine: j701/2011-01-10/11:25 Library: 7.01.047 Platform: Win 32 Installer: j701a_win.exe InstallPath: c:/program files/j701 On Mon, Mar 14, 2011 at 1:20 PM, Dan Bron <[email protected]> wrote: > "Nobody optimizes any more; premature abstraction is the new evil" - > @stuartsierra > > Stuart Sierra http://twitter.com/#!/stuartsierra/status/34967735423205376 > > -Dan > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Devon McCormick > Sent: Monday, March 14, 2011 11:27 AM > To: Programming forum > Subject: Re: [Jprogramming] Recursive algorithm > > "Premature optimization is the root of all evil." - Tony Hoare > > On Mon, Mar 14, 2011 at 9:30 AM, Robert O'Boyle <[email protected] > >wrote: > > > ... > > I also read in either J for C or LJ that one should avoid control > > structures > > (for, while, etc) as much as possible due to the performance penalty. > > > > ... > > -- > Devon McCormick, CFA > ^me^ at acm. > org is my > preferred e-mail > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
