From: "David G. Andersen" Date: 2004-11-06T06:31:33+09:00 Subject: Re: Ruby is a slow performer On Sat, Nov 06, 2004 at 06:23:41AM +0900, Christian Szegedy scribed: > gabriele renzi wrote: > > >About the shootout. Most of the stuff is plan useless in ruby. > >You won't implemente heapsort in ruby, cause you have sort/sort_by. > >Nor you would use > >http://shootout.alioth.debian.org/lang/ruby/random.ruby.html > >because you have rand(). > > You are correct. I would say that the shootout is extremely > misleading, for example the Python people do dubious tricks > to make it look fast: for example the matrix multiplication is > implemented by calling the an extension method. Why is that unrealistic? You could do the same in Ruby by implementing the library 'Matrix' class in C. We already have a library that handles the stuff; it's just a matter of optimization (== time == extra code in C that's harder to maintain, unfortunately). I actually played with this a bit. Right now, using the Ruby matrix class does two things to that test: a) Reduces the lines of code by nearly half b) Increases the runtime by a factor of two. (ouch) If we had a superfast matrix class, it would give (a) along with decreasing the runtime by a factor of ten or so. Sounds reasonable. The same test in matlab would be about 1/4 the lines of code and 20x faster if implemented the way it should be. Admittedly, most people would probably use external hooks to lapack for serious matrix manipulation, but who's counting? There's something to be said, in all honesty, for fast built-in library support. The shootout _is_ useful for understanding some general aspects of the languages, and for looking for things that you might want to really work on speeding up (say, for instance, the fact that Ruby's hash accesses seem to be about 1/2 the speed of Perl's. ;-) -Dave -- work: dga@lcs.mit.edu me: dga@pobox.com MIT Laboratory for Computer Science http://www.angio.net/