From: Jacob Fugal Date: 2005-04-07T06:17:03+09:00 Subject: Re: new! On Apr 6, 2005 2:24 PM, Boris Glawe wrote: > The difference is speed!! I have an algoithm that runs 5 seconds with c++ > and 16 minutes with ruby on my machine. The speed "problem" exists with > all skripting languages (perl,php, etc), it's not ruby's fault. While I won't dispute the relative slowness of scripting languages compared to compiled languages, I must assume you made a typo. 16 minutes?! I copy the script you paste below into a file and run it and it takes fractions of a second. Possibly benchmarking it for 10^X iterations will take longer than C, but not by 2 orders of magnitude (5 seconds to 960 seconds). Probably 5 seconds versus 16 *seconds* when benchmarked? I'm too lazy to actually perform the benchmark myself, but felt it necessary to call this to attention... Jacob Fugal (ruby version included below for reference) > #!/usr/bin/ruby > > class Base > attr_reader :var > > def initialize(v) > @var = v > end > > def increase > @var = @var + 1 > end > end > > class Derived < Base > > attr_reader :text > > def initialize(x, t) > super(x) > @text = t > end > > def append(t) > @text = @text + t > end > > end > > d = Derived.new(5, "hallo") > d.increase > > print d.var.to_s + "\n" > print d.text + "\n" > > d.append("bye") > > print d.text + "\n"