# Ruby Performance

**URL:** <https://rubytalk.org/t/ruby-performance/20120>\
**Category:** ruby-talk\
**Created:** [12 August 2005 14:27 UTC](https://rubytalk.org/t/ruby-performance/20120 "2005-08-12T14:27:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bradley\_Kite](https://avatars.discourse-cdn.com/v4/letter/b/bbce88/32.png) [@Bradley\_Kite](https://rubytalk.org/u/Bradley_Kite)\
**Post date:** [12 August 2005 14:27 UTC](https://rubytalk.org/t/ruby-performance/20120/1 "2005-08-12T14:27:54Z")

</div>

Hi all,

I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
trying to achieve that other scripting languages do not already offer (Apart  
from the syntactic differences of yet another scripting language, that is).  
The reason I ask is that it must offer something that is worth a lot considering  
it runs twice as slowly as Perl (see below).

I was also interested in comparing the performance of Ruby against something  
like Perl, and (although this test is VERY simple) thought that I'd benchmark  
a simple counter in both Ruby and Perl. The number that it counts to  
is arbitrary,  
I started with 4294967296 and kept reducing it because I got bored of waiting).  
Code is provided below.

Any way, on a 3Ghz P4 CPU, I got the following results:

Perl:  
real 0m24.569s  
user 0m24.499s  
sys 0m0.068s

Ruby:  
real 0m57.218s  
user 0m57.108s  
sys 0m0.109s

(Just out of interest I did it in C as well):

(Average Run, non-optimised)  
real 0m0.142s  
user 0m0.136s  
sys 0m0.005s

(Average Run, -O3 optimisations):  
real 0m0.074s  
user 0m0.070s  
sys 0m0.004s

> **···**
>
> ##################################
> 
> #!/usr/bin/perl  
> my $num = 0;
> 
> while ($num \< 94967295)  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;$num += 1;  
> }
> 
> ###############
> 
> #!/usr/bin/ruby  
> num = 0
> 
> while num \< 94967295 do  
> &nbsp;&nbsp;&nbsp;&nbsp;num += 1  
> end
> 
> ###############
> 
> int main()  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;int counter = 0;
> 
> &nbsp;&nbsp;&nbsp;&nbsp;while (counter \< 94967295)  
> &nbsp;&nbsp;&nbsp;&nbsp;{  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counter += 1;  
> &nbsp;&nbsp;&nbsp;&nbsp;}  
> }

---

<div class="post-metadata">

**Author:** ![Julian\_Leviston](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Julian\_Leviston](https://rubytalk.org/u/Julian_Leviston)\
**Post date:** [12 August 2005 14:37 UTC](https://rubytalk.org/t/ruby-performance/20120/2 "2005-08-12T14:37:09Z")

</div>

Hey,

It's faster, easier and more enjoyable to write better, cleaner, easier-to-understand code. 😉

Julian.

> **···**
>
> On 13/08/2005, at 12:27 AM, Bradley Kite wrote:
> 
> > Hi all,
> > 
> > I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> > trying to achieve that other scripting languages do not already offer (Apart  
> > from the syntactic differences of yet another scripting language, that is).  
> > The reason I ask is that it must offer something that is worth a lot considering  
> > it runs twice as slowly as Perl (see below).
> > 
> > I was also interested in comparing the performance of Ruby against something  
> > like Perl, and (although this test is VERY simple) thought that I'd benchmark  
> > a simple counter in both Ruby and Perl. The number that it counts to  
> > is arbitrary,  
> > I started with 4294967296 and kept reducing it because I got bored of waiting).  
> > Code is provided below.
> > 
> > Any way, on a 3Ghz P4 CPU, I got the following results:
> > 
> > Perl:  
> > real 0m24.569s  
> > user 0m24.499s  
> > sys 0m0.068s
> > 
> > Ruby:  
> > real 0m57.218s  
> > user 0m57.108s  
> > sys 0m0.109s
> > 
> > (Just out of interest I did it in C as well):
> > 
> > (Average Run, non-optimised)  
> > real 0m0.142s  
> > user 0m0.136s  
> > sys 0m0.005s
> > 
> > (Average Run, -O3 optimisations):  
> > real 0m0.074s  
> > user 0m0.070s  
> > sys 0m0.004s
> > 
> > ##################################
> > 
> > #!/usr/bin/perl  
> > my $num = 0;
> > 
> > while ($num \< 94967295)  
> > {  
> > &nbsp;&nbsp;&nbsp;&nbsp;$num += 1;  
> > }
> > 
> > ###############
> > 
> > #!/usr/bin/ruby  
> > num = 0
> > 
> > while num \< 94967295 do  
> > &nbsp;&nbsp;&nbsp;&nbsp;num += 1  
> > end
> > 
> > ###############
> > 
> > int main()  
> > {  
> > &nbsp;&nbsp;&nbsp;&nbsp;int counter = 0;
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;while (counter \< 94967295)  
> > &nbsp;&nbsp;&nbsp;&nbsp;{  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counter += 1;  
> > &nbsp;&nbsp;&nbsp;&nbsp;}  
> > }

---

<div class="post-metadata">

**Author:** ![Thomas\_E\_Enebo](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@Thomas\_E\_Enebo](https://rubytalk.org/u/Thomas_E_Enebo)\
**Post date:** [12 August 2005 15:00 UTC](https://rubytalk.org/t/ruby-performance/20120/3 "2005-08-12T15:00:01Z")

</div>

On Fri, 12 Aug 2005, Bradley Kite defenestrated me:

> Hi all,
> 
> I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> trying to achieve that other scripting languages do not already offer (Apart  
> from the syntactic differences of yet another scripting language, that is).  
> The reason I ask is that it must offer something that is worth a lot  
> considering it runs twice as slowly as Perl (see below).

(I apologize in advance to any other Perl fans in advance)

&nbsp;&nbsp;If you think that Ruby's language does not offer A LOT over Perl's  
syntax, then you may want to go back to Perl. I came from the Perl  
camp and I have not looked back (other than reading the crazy Exegesis  
writings -- which makes me even happier to be using Ruby). I loved  
Perl and used it for over a decade. I used to read people asking the  
same performance questions you are asking now to the perl lists, but it  
was about why you would use a scripting language over a real one(tm) 🙂

&nbsp;&nbsp;I think performance is largely a red herring. Most scripts I have  
written have not even had a performance attribute. If it took 2 or 3  
times longer it would not have mattered. Usually, anytime performance  
did matter it was a matter of an external force...Like accessing a database.  
I think few times I have written scripts which took 8+ hours to process  
data. In all cases this was one time conversion and a 16 hour run time  
would not have mattered.

&nbsp;&nbsp;It sounds like Ruby's performance will get better with Rite (Ruby 2). Even  
if it didn't I am more than happy with how it performs now. In other words  
it does not seem slow when I work with it.

> **···**
>
> > [micro-benchmark removed for brevity]
> 
> --  
> + [http://www.tc.umn.edu/~enebo](http://www.tc.umn.edu/~enebo) +---- [mailto:enebo@acm](mailto:enebo@acm).org ----+
> 
> > Thomas E Enebo, Protagonist | "Luck favors the prepared |  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\> mind." -Louis Pasteur |

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [12 August 2005 15:06 UTC](https://rubytalk.org/t/ruby-performance/20120/4 "2005-08-12T15:06:20Z")

</div>

Bradley Kite wrote:

> Hi all,
> 
> I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> trying to achieve that other scripting languages do not already offer  
> (Apart from the syntactic differences of yet another scripting  
> language, that is).  
> The reason I ask is that it must offer something that is worth a lot  
> considering it runs twice as slowly as Perl (see below).
> 
> I was also interested in comparing the performance of Ruby against  
> something like Perl, and (although this test is VERY simple) thought  
> that I'd benchmark  
> a simple counter in both Ruby and Perl. The number that it counts to  
> is arbitrary,  
> I started with 4294967296 and kept reducing it because I got bored of  
> waiting). Code is provided below.
> 
> Any way, on a 3Ghz P4 CPU, I got the following results:
> 
> Perl:  
> real 0m24.569s  
> user 0m24.499s  
> sys 0m0.068s
> 
> Ruby:  
> real 0m57.218s  
> user 0m57.108s  
> sys 0m0.109s
> 
> (Just out of interest I did it in C as well):
> 
> (Average Run, non-optimised)  
> real 0m0.142s  
> user 0m0.136s  
> sys 0m0.005s
> 
> (Average Run, -O3 optimisations):  
> real 0m0.074s  
> user 0m0.070s  
> sys 0m0.004s
> 
> ##################################
> 
> #!/usr/bin/perl  
> my $num = 0;
> 
> while ($num \< 94967295)  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;$num += 1;  
> }
> 
> ###############
> 
> #!/usr/bin/ruby  
> num = 0
> 
> while num \< 94967295 do  
> &nbsp;&nbsp;&nbsp;&nbsp;num += 1  
> end
> 
> ###############
> 
> int main()  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;int counter = 0;
> 
> &nbsp;&nbsp;&nbsp;&nbsp;while (counter \< 94967295)  
> &nbsp;&nbsp;&nbsp;&nbsp;{  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counter += 1;  
> &nbsp;&nbsp;&nbsp;&nbsp;}  
> }

Just out of curiosity: did you also benchmark these Ruby idioms (which I  
regard more typical):

94967295.times do  
end

for i in 0..94967295 do  
end

0.upto 94967295 do  
end

Kind regards

&nbsp;&nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![Lothar\_Scholz2](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@Lothar\_Scholz2](https://rubytalk.org/u/Lothar_Scholz2)\
**Post date:** [12 August 2005 15:23 UTC](https://rubytalk.org/t/ruby-performance/20120/5 "2005-08-12T15:23:21Z")

</div>

Hello Bradley,

> Hi all,

> I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> trying to achieve that other scripting languages do not already offer (Apart  
> from the syntactic differences of yet another scripting language, that is).

Why ?

Python \<-\> Ruby:  
Better consistent object modell, no indentation based language, but  
Python is without doubt the hardest competitor. And its more or less  
the same decision you must do when buying ice cream: Vanilla or  
Chocolat ? Just a different flavour.

Perl \<-\> Ruby:  
Perl is so ugly and difficult i don't want to compare it with ruby.  
I doubt that it is possible to develop huge Perl programs where you  
have a changing team of different programmers working on the same  
code.

PHP \<-\> Ruby:  
PHP is only a valid alternative for web development. And it is ugly  
and unorthogonal.

TCL \<-\> Ruby:  
Tcl is perfect for embedding it in apps and has a good infrastructure  
(libraries, implementation) but the language is terrible unconvenient  
for writing larger pure TCL programs.

> **···**
>
> --  
> Best regards, emailto: scholz at scriptolutions dot com  
> Lothar Scholz [http://www.ruby-ide.com](http://www.ruby-ide.com)  
> CTO Scriptolutions Ruby, PHP, Python IDE 's

---

<div class="post-metadata">

**Author:** ![Adrian\_Howard](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@Adrian\_Howard](https://rubytalk.org/u/Adrian_Howard)\
**Post date:** [12 August 2005 15:38 UTC](https://rubytalk.org/t/ruby-performance/20120/6 "2005-08-12T15:38:54Z")

</div>

Well, non-idiomatic integer arithmatic might run twice as slowly 🙂

Who cares? I certainly don't since the vast majority of my cycles are not spent in tight loops doing integer arithmetic. If it was I wouldn't be using Perl or Ruby (I'd probably be using Lisp 🙂

The only performance figures that are important are whether tasks are fast enough in a particular context. Otherwise we'd all be writing assembler.

My pitch for Ruby to a Perl programmer would be:

- Perl 6 now! Many useful things that Perl 5 lacks and that Perl 6 will give you like a decent built in OO system, classes as proper objects, coroutines, simple block passing, etc. Ruby does now.

- Ruby has a simple threading system that actually works

- Ruby has the same TIMTOWTDI attitude as Perl so you'll feel at home, but has some better ways of doing some things that can make your code considerably less ugly.

- A more concise clearer syntax for many operations, which means you type less and your code is easier to maintain.

Cheers,

Adrian

> **···**
>
> On 12 Aug 2005, at 15:27, Bradley Kite wrote:
> 
> > Hi all,
> > 
> > I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> > trying to achieve that other scripting languages do not already offer (Apart  
> > from the syntactic differences of yet another scripting language, that is).  
> > The reason I ask is that it must offer something that is worth a lot considering  
> > it runs twice as slowly as Perl (see below).

---

<div class="post-metadata">

**Author:** ![Zed\_A\_Shaw](https://avatars.discourse-cdn.com/v4/letter/z/5fc32e/32.png) [@Zed\_A\_Shaw](https://rubytalk.org/u/Zed_A_Shaw)\
**Post date:** [12 August 2005 21:28 UTC](https://rubytalk.org/t/ruby-performance/20120/7 "2005-08-12T21:28:00Z")

</div>

Wow, that C program is really fast, especially with the -O3 option.

Too bad there wasn't a way to hook your spiffy ultra-fast C loop into  
Ruby. Wouldn't that be great? Some kind of "C" extension thing.

Then, your Ruby (and any language that can 'hook' C) is basically as fast  
as C or even Assembler if you really get desperate.

Too bad that didn't exist. Oh well, I guess you'll have to keep testing  
these loops and comparing them with Perl.

Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

\<snip\>

> I started with 4294967296 and kept reducing it because I got bored of  
> waiting).  
> Code is provided below.
> 
> Any way, on a 3Ghz P4 CPU, I got the following results:

\<snip\>

> **···**
>
> > (Just out of interest I did it in C as well):
> > 
> > (Average Run, non-optimised)  
> > real 0m0.142s  
> > user 0m0.136s  
> > sys 0m0.005s
> > 
> > (Average Run, -O3 optimisations):  
> > real 0m0.074s  
> > user 0m0.070s  
> > sys 0m0.004s

---

<div class="post-metadata">

**Author:** ![H.P\_Gobelli](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@H.P\_Gobelli](https://rubytalk.org/u/H.P_Gobelli)\
**Post date:** [13 August 2005 09:16 UTC](https://rubytalk.org/t/ruby-performance/20120/8 "2005-08-13T09:16:12Z")

</div>

> Hi all,
> 
> I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> trying to achieve that other scripting languages do not already offer (Apart  
> from the syntactic differences of yet another scripting language, that is).  
> The reason I ask is that it must offer something that is worth a lot considering  
> it runs twice as slowly as Perl (see below).
> 
> I was also interested in comparing the performance of Ruby against something  
> like Perl, and (although this test is VERY simple) thought that I'd benchmark  
> a simple counter in both Ruby and Perl. The number that it counts to  
> is arbitrary,  
> I started with 4294967296 and kept reducing it because I got bored of waiting).  
> Code is provided below.
> 
> Any way, on a 3Ghz P4 CPU, I got the following results:
> 
> Perl:  
> real 0m24.569s  
> user 0m24.499s  
> sys 0m0.068s
> 
> Ruby:  
> real 0m57.218s  
> user 0m57.108s  
> sys 0m0.109s

I think the performance issues will be fixed with the new virtual  
machine they are developing, just look at this:

$ time ruby1.8 perf.rb

real 0m57.328s  
user 0m52.766s  
sys 0m0.178s

$ time ruby1.9 perf.rb

real 0m41.883s  
user 0m40.081s  
sys 0m0.085s

$ time ruby1.9 -rite perf.rb

real 0m2.528s  
user 0m2.351s  
sys 0m0.010s

ruby1.9 -rite means run ruby with the new VM,

Regards,

Paolo.

> **···**
>
> Il giorno ven, 12/08/2005 alle 23.27 +0900, Bradley Kite ha scritto:
> 
> > (Just out of interest I did it in C as well):
> > 
> > (Average Run, non-optimised)  
> > real 0m0.142s  
> > user 0m0.136s  
> > sys 0m0.005s
> > 
> > (Average Run, -O3 optimisations):  
> > real 0m0.074s  
> > user 0m0.070s  
> > sys 0m0.004s
> > 
> > ##################################
> > 
> > #!/usr/bin/perl  
> > my $num = 0;
> > 
> > while ($num \< 94967295)  
> > {  
> > &nbsp;&nbsp;&nbsp;&nbsp;$num += 1;  
> > }
> > 
> > ###############
> > 
> > #!/usr/bin/ruby  
> > num = 0
> > 
> > while num \< 94967295 do  
> > &nbsp;&nbsp;&nbsp;&nbsp;num += 1  
> > end
> > 
> > ###############
> > 
> > int main()  
> > {  
> > &nbsp;&nbsp;&nbsp;&nbsp;int counter = 0;
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;while (counter \< 94967295)  
> > &nbsp;&nbsp;&nbsp;&nbsp;{  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counter += 1;  
> > &nbsp;&nbsp;&nbsp;&nbsp;}  
> > }

---

<div class="post-metadata">

**Author:** ![Isaac\_Gouy1](https://avatars.discourse-cdn.com/v4/letter/i/4bbf92/32.png) [@Isaac\_Gouy1](https://rubytalk.org/u/Isaac_Gouy1)\
**Post date:** [15 August 2005 16:16 UTC](https://rubytalk.org/t/ruby-performance/20120/9 "2005-08-15T16:16:13Z")

</div>

Bradley Kite wrote:

> Hi all,
> 
> I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> trying to achieve that other scripting languages do not already offer (Apart  
> from the syntactic differences of yet another scripting language, that is).  
> The reason I ask is that it must offer something that is worth a lot considering  
> it runs twice as slowly as Perl (see below).
> 
> I was also interested in comparing the performance of Ruby against something  
> like Perl, and (although this test is VERY simple) thought that I'd benchmark  
> a simple counter in both Ruby and Perl.

That's even more simplistic than the benchmark programs on the Computer  
Language Shootout 🙂

Here's Ruby vs Perl  
[http://shootout.alioth.debian.org/benchmark.php?test=all&lang=ruby&sort=fullcpu](http://shootout.alioth.debian.org/benchmark.php?test=all&lang=ruby&sort=fullcpu)

and here are the old Doug Bagley programs  
[http://shootout.alioth.debian.org/old/benchmark.php?test=all&lang=ruby&sort=fullcpu](http://shootout.alioth.debian.org/old/benchmark.php?test=all&lang=ruby&sort=fullcpu)

---

<div class="post-metadata">

**Author:** ![Bradley\_Kite](https://avatars.discourse-cdn.com/v4/letter/b/bbce88/32.png) [@Bradley\_Kite](https://rubytalk.org/u/Bradley_Kite)\
**Post date:** [12 August 2005 15:19 UTC](https://rubytalk.org/t/ruby-performance/20120/10 "2005-08-12T15:19:32Z")

</div>

Those idioms are around 21 seconds each in Ruby.

In perl, its 11 seconds to do this:

for (0..94967295)  
{

}

The question is not so much about the run-time of a particular action,  
but (in a web-based environment, for example) its more to do with  
the number of concurrent users you can have without having to buy  
more hardware.

> **···**
>
> --  
> Brad.
> 
> On 12/08/05, Robert Klemme \<bob.news@gmx.net\> wrote:
> 
> > Bradley Kite wrote:  
> > \> Hi all,  
> > \>  
> > \> I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> > \> trying to achieve that other scripting languages do not already offer  
> > \> (Apart from the syntactic differences of yet another scripting  
> > \> language, that is).  
> > \> The reason I ask is that it must offer something that is worth a lot  
> > \> considering it runs twice as slowly as Perl (see below).  
> > \>  
> > \> I was also interested in comparing the performance of Ruby against  
> > \> something like Perl, and (although this test is VERY simple) thought  
> > \> that I'd benchmark  
> > \> a simple counter in both Ruby and Perl. The number that it counts to  
> > \> is arbitrary,  
> > \> I started with 4294967296 and kept reducing it because I got bored of  
> > \> waiting). Code is provided below.  
> > \>  
> > \> Any way, on a 3Ghz P4 CPU, I got the following results:  
> > \>  
> > \> Perl:  
> > \> real 0m24.569s  
> > \> user 0m24.499s  
> > \> sys 0m0.068s  
> > \>  
> > \> Ruby:  
> > \> real 0m57.218s  
> > \> user 0m57.108s  
> > \> sys 0m0.109s  
> > \>  
> > \> (Just out of interest I did it in C as well):  
> > \>  
> > \> (Average Run, non-optimised)  
> > \> real 0m0.142s  
> > \> user 0m0.136s  
> > \> sys 0m0.005s  
> > \>  
> > \> (Average Run, -O3 optimisations):  
> > \> real 0m0.074s  
> > \> user 0m0.070s  
> > \> sys 0m0.004s  
> > \>  
> > \> ##################################  
> > \>  
> > \> #!/usr/bin/perl  
> > \> my $num = 0;  
> > \>  
> > \> while ($num \< 94967295)  
> > \> {  
> > \> $num += 1;  
> > \> }  
> > \>  
> > \> ###############  
> > \>  
> > \> #!/usr/bin/ruby  
> > \> num = 0  
> > \>  
> > \> while num \< 94967295 do  
> > \> num += 1  
> > \> end  
> > \>  
> > \> ###############  
> > \>  
> > \> int main()  
> > \> {  
> > \> int counter = 0;  
> > \>  
> > \> while (counter \< 94967295)  
> > \> {  
> > \> counter += 1;  
> > \> }  
> > \> }
> > 
> > Just out of curiosity: did you also benchmark these Ruby idioms (which I  
> > regard more typical):
> > 
> > 94967295.times do  
> > end
> > 
> > for i in 0..94967295 do  
> > end
> > 
> > 0.upto 94967295 do  
> > end
> > 
> > Kind regards
> > 
> > &nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![Adrian\_Howard](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@Adrian\_Howard](https://rubytalk.org/u/Adrian_Howard)\
**Post date:** [12 August 2005 15:41 UTC](https://rubytalk.org/t/ruby-performance/20120/11 "2005-08-12T15:41:08Z")

</div>

[snip]

> Perl \<-\> Ruby:  
> Perl is so ugly and difficult i don't want to compare it with ruby.  
> I doubt that it is possible to develop huge Perl programs where you  
> have a changing team of different programmers working on the same  
> code.

[snip]

As somebody who does this on a regular basis I'd have to disagree 🙂

Adrian

> **···**
>
> On 12 Aug 2005, at 16:23, Lothar Scholz wrote:

---

<div class="post-metadata">

**Author:** ![tony\_summerfelt](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@tony\_summerfelt](https://rubytalk.org/u/tony_summerfelt)\
**Post date:** [12 August 2005 16:20 UTC](https://rubytalk.org/t/ruby-performance/20120/12 "2005-08-12T16:20:58Z")

</div>

what do you mean by 'larger' (ie. # of lines of code)

i think one thing tcl has over the rest is tk. even for 'larger' programs.

i do all my gui prototyping in tcl/tk strictly for look and feel. then  
i try to get the same result in ruby and invariably one gui api or  
another problem shows up...

> **···**
>
> Lothar Scholz wrote on 8/12/2005 11:23 AM: \> TCL \<-\> Ruby:
> 
> > Tcl is perfect for embedding it in apps and has a good infrastructure  
> > (libraries, implementation) but the language is terrible unconvenient  
> > for writing larger pure TCL programs.
> 
> --  
> [http://home.cogeco.ca/~tsummerfelt1](http://home.cogeco.ca/~tsummerfelt1)  
> telnet://ventedspleen.dyndns.org

---

<div class="post-metadata">

**Author:** ![Lothar\_Scholz2](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@Lothar\_Scholz2](https://rubytalk.org/u/Lothar_Scholz2)\
**Post date:** [12 August 2005 16:37 UTC](https://rubytalk.org/t/ruby-performance/20120/13 "2005-08-12T16:37:07Z")

</div>

Hello Adrian,

> > Hi all,
> > 
> > I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> > trying to achieve that other scripting languages do not already  
> > offer (Apart  
> > from the syntactic differences of yet another scripting language,  
> > that is).  
> > The reason I ask is that it must offer something that is worth a  
> > lot considering  
> > it runs twice as slowly as Perl (see below).

> Well, non-idiomatic integer arithmatic might run twice as slowly 🙂

> Who cares? I certainly don't since the vast majority of my cycles are  
> not spent in tight loops doing integer arithmetic. If it was I  
> wouldn't be using Perl or Ruby (I'd probably be using Lisp 🙂

> The only performance figures that are important are whether tasks are  
> fast enough in a particular context. Otherwise we'd all be writing  
> assembler.

> My pitch for Ruby to a Perl programmer would be:

> - Perl 6 now! Many useful things that Perl 5 lacks and that Perl  
> 6 will give you like a decent built in OO system, classes as proper  
> objects, coroutines, simple block passing, etc. Ruby does now.

Yes thats also going to piss me off. I thought they got a few paid  
full time worker on the language (at least one or two from  
activestate). But i see almost no progress in Perl 6.

Maybe they did a huge mistake when they dicided that all features and  
programming paradigms currently known in the software world should be  
supported by Perl6.

Sometimes less is more. Especially in language design.

> **···**
>
> > On 12 Aug 2005, at 15:27, Bradley Kite wrote:
> 
> --  
> Best regards, emailto: scholz at scriptolutions dot com  
> Lothar Scholz [http://www.ruby-ide.com](http://www.ruby-ide.com)  
> CTO Scriptolutions Ruby, PHP, Python IDE 's

---

<div class="post-metadata">

**Author:** ![Robert9](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@Robert9](https://rubytalk.org/u/Robert9)\
**Post date:** [12 August 2005 23:36 UTC](https://rubytalk.org/t/ruby-performance/20120/14 "2005-08-12T23:36:13Z")

</div>

zedshaw@zedshaw.com wrote:

> Wow, that C program is really fast, especially with the -O3 option.
> 
> Too bad there wasn't a way to hook your spiffy ultra-fast C loop into  
> Ruby. Wouldn't that be great? Some kind of "C" extension thing.
> 
> Then, your Ruby (and any language that can 'hook' C) is basically as fast  
> as C or even Assembler if you really get desperate.
> 
> Too bad that didn't exist. Oh well, I guess you'll have to keep testing  
> these loops and comparing them with Perl.
> 
> Zed A. Shaw  
> [http://www.zedshaw.com/](http://www.zedshaw.com/)

He could easily have done that with Tcl. Oh wait, you were being  
sarcastic!

Robert

---

<div class="post-metadata">

**Author:** ![Austin\_Ziegler5](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/austin_ziegler5/32/1985_2.png) [@Austin\_Ziegler5](https://rubytalk.org/u/Austin_Ziegler5)\
**Post date:** [15 August 2005 16:24 UTC](https://rubytalk.org/t/ruby-performance/20120/15 "2005-08-15T16:24:10Z")

</div>

And, like Mr Kite's test, none of the Alioth shootout benchmarks are  
worth squat.

-austin

> **···**
>
> On 8/15/05, Isaac Gouy \<igouy@yahoo.com\> wrote:
> 
> > Bradley Kite wrote:  
> > \> I was also interested in comparing the performance of Ruby against something  
> > \> like Perl, and (although this test is VERY simple) thought that I'd benchmark  
> > \> a simple counter in both Ruby and Perl.  
> > That's even more simplistic than the benchmark programs on the Computer  
> > Language Shootout 🙂
> > 
> > Here's Ruby vs Perl  
> > [http://shootout.alioth.debian.org/benchmark.php?test=all&lang=ruby&sort=fullcpu](http://shootout.alioth.debian.org/benchmark.php?test=all&lang=ruby&sort=fullcpu)
> > 
> > and here are the old Doug Bagley programs  
> > [http://shootout.alioth.debian.org/old/benchmark.php?test=all&lang=ruby&sort=fullcpu](http://shootout.alioth.debian.org/old/benchmark.php?test=all&lang=ruby&sort=fullcpu)
> 
> --  
> Austin Ziegler \* halostatue@gmail.com  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Alternate: austin@halostatue.ca

---

<div class="post-metadata">

**Author:** ![Julian\_Leviston](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Julian\_Leviston](https://rubytalk.org/u/Julian_Leviston)\
**Post date:** [12 August 2005 15:25 UTC](https://rubytalk.org/t/ruby-performance/20120/16 "2005-08-12T15:25:47Z")

</div>

The bottleneck is usually the database, tho... no? 🙂

Read the ruby on rails book - and then you'll get some real-world-applications... take a look at basecamp - that's running with THOUSANDS of users... not sure how many concurrent... and it's all of one to two machines...

Julian.

> **···**
>
> On 13/08/2005, at 1:19 AM, Bradley Kite wrote:
> 
> > Those idioms are around 21 seconds each in Ruby.
> > 
> > In perl, its 11 seconds to do this:
> > 
> > for (0..94967295)  
> > {
> > 
> > }
> > 
> > The question is not so much about the run-time of a particular action,  
> > but (in a web-based environment, for example) its more to do with  
> > the number of concurrent users you can have without having to buy  
> > more hardware.
> > 
> > --  
> > Brad.
> > 
> > On 12/08/05, Robert Klemme \<bob.news@gmx.net\> wrote:
> > 
> > > Bradley Kite wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > I'm a relatively new Ruby programmer, I am curious as to what Ruby is  
> > > > trying to achieve that other scripting languages do not already offer  
> > > > (Apart from the syntactic differences of yet another scripting  
> > > > language, that is).  
> > > > The reason I ask is that it must offer something that is worth a lot  
> > > > considering it runs twice as slowly as Perl (see below).
> > > > 
> > > > I was also interested in comparing the performance of Ruby against  
> > > > something like Perl, and (although this test is VERY simple) thought  
> > > > that I'd benchmark  
> > > > a simple counter in both Ruby and Perl. The number that it counts to  
> > > > is arbitrary,  
> > > > I started with 4294967296 and kept reducing it because I got bored of  
> > > > waiting). Code is provided below.
> > > > 
> > > > Any way, on a 3Ghz P4 CPU, I got the following results:
> > > > 
> > > > Perl:  
> > > > real 0m24.569s  
> > > > user 0m24.499s  
> > > > sys 0m0.068s
> > > > 
> > > > Ruby:  
> > > > real 0m57.218s  
> > > > user 0m57.108s  
> > > > sys 0m0.109s
> > > > 
> > > > (Just out of interest I did it in C as well):
> > > > 
> > > > (Average Run, non-optimised)  
> > > > real 0m0.142s  
> > > > user 0m0.136s  
> > > > sys 0m0.005s
> > > > 
> > > > (Average Run, -O3 optimisations):  
> > > > real 0m0.074s  
> > > > user 0m0.070s  
> > > > sys 0m0.004s
> > > > 
> > > > ##################################
> > > > 
> > > > #!/usr/bin/perl  
> > > > my $num = 0;
> > > > 
> > > > while ($num \< 94967295)  
> > > > {  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;$num += 1;  
> > > > }
> > > > 
> > > > ###############
> > > > 
> > > > #!/usr/bin/ruby  
> > > > num = 0
> > > > 
> > > > while num \< 94967295 do  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;num += 1  
> > > > end
> > > > 
> > > > ###############
> > > > 
> > > > int main()  
> > > > {  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;int counter = 0;
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;while (counter \< 94967295)  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;{  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counter += 1;  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;}  
> > > > }
> > > 
> > > Just out of curiosity: did you also benchmark these Ruby idioms (which I  
> > > regard more typical):
> > > 
> > > 94967295.times do  
> > > end
> > > 
> > > for i in 0..94967295 do  
> > > end
> > > 
> > > 0.upto 94967295 do  
> > > end
> > > 
> > > Kind regards
> > > 
> > > &nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![Brock\_Weaver](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@Brock\_Weaver](https://rubytalk.org/u/Brock_Weaver)\
**Post date:** [12 August 2005 15:58 UTC](https://rubytalk.org/t/ruby-performance/20120/17 "2005-08-12T15:58:07Z")

</div>

I'm not much of a Perl guy, so I don't know what TIMTOWTDI stands for.

This Is My T... O... Way To Do It?

Help a brother out 🙂

Also, somebody mentioned slashdot -- does this mean we should bring up Nazis  
too so we can kill the thread?

I'm sorry, I'm a little caffiened up today.

I do have a valid comment though: I was running ruby from a USB stick, and  
it was horribly slow (2-3 minutes to run "ruby -v"). Installing onto my 2nd  
logical partition (D:) helped, but it was still about 30 seconds to do the  
same version check. Installing onto C: -- same physical drive as D: -- made  
"ruby -v" practically instantaneous.

Unfortunately, yes I have Windows, so I'm sure that makes a difference.

> **···**
>
> On 8/12/05, Adrian Howard \<adrianh@quietstars.com\> wrote:
> 
> > On 12 Aug 2005, at 16:23, Lothar Scholz wrote:  
> > [snip]  
> > \> Perl \<-\> Ruby:  
> > \> Perl is so ugly and difficult i don't want to compare it with ruby.  
> > \> I doubt that it is possible to develop huge Perl programs where you  
> > \> have a changing team of different programmers working on the same  
> > \> code.  
> > [snip]
> > 
> > As somebody who does this on a regular basis I'd have to disagree 🙂
> > 
> > Adrian
> 
> --  
> Brock Weaver  
> [http://www.circaware.com](http://www.circaware.com)

---

<div class="post-metadata">

**Author:** ![Lothar\_Scholz2](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@Lothar\_Scholz2](https://rubytalk.org/u/Lothar_Scholz2)\
**Post date:** [12 August 2005 16:39 UTC](https://rubytalk.org/t/ruby-performance/20120/18 "2005-08-12T16:39:03Z")

</div>

Hello Adrian,

> **···**
>
> > On 12 Aug 2005, at 16:23, Lothar Scholz wrote:  
> > [snip]
> > 
> > > Perl \<-\> Ruby:  
> > > Perl is so ugly and difficult i don't want to compare it with ruby.  
> > > I doubt that it is possible to develop huge Perl programs where you  
> > > have a changing team of different programmers working on the same  
> > > code.
> > 
> > [snip]
> 
> > As somebody who does this on a regular basis I'd have to disagree 🙂
> 
> Maybe your collegues are maybe better motivated, better paid and  
> better educated, then the onces i had to work with in the past  
> (on a very small project - in terms of LOC not of importance for the company).
> 
> --  
> Best regards, emailto: scholz at scriptolutions dot com  
> Lothar Scholz [http://www.ruby-ide.com](http://www.ruby-ide.com)  
> CTO Scriptolutions Ruby, PHP, Python IDE 's

---

<div class="post-metadata">

**Author:** ![Lothar\_Scholz2](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@Lothar\_Scholz2](https://rubytalk.org/u/Lothar_Scholz2)\
**Post date:** [12 August 2005 16:54 UTC](https://rubytalk.org/t/ruby-performance/20120/19 "2005-08-12T16:54:51Z")

</div>

Hello tony,

> > Tcl is perfect for embedding it in apps and has a good infrastructure  
> > (libraries, implementation) but the language is terrible unconvenient  
> > for writing larger pure TCL programs.

> what do you mean by 'larger' (ie. # of lines of code)

I mean complexer algorithms, more options and influces from the outside  
world, more tighter connected modules.

Things where the OO and abstraction facilities of "real languages"  
start shining. So instead large i should have written more complex.

> i think one thing tcl has over the rest is tk. even for 'larger' programs.

> i do all my gui prototyping in tcl/tk strictly for look and feel. then  
> i try to get the same result in ruby and invariably one gui api or  
> another problem shows up...

Yes, i loved TK and did a lot of TK/TCL programming in the past (as  
you can find out when searching for my name in the comp.lang.tcl  
newsgroup). And it is such a pitty that the TK evolution came to a  
standstill for amost 10 years, with complete ignorance of changing  
requirements, as i think technically TK is still the best toolkit out  
there (binding events, matrix layout manager, canvas and text  
widgets).

And this teached me a lession what can happen if too many people are  
just saying: Its good enough for me. Sometimes when they realize that  
this is not so anymore then it's too late to get back lost ground.

> **···**
>
> > Lothar Scholz wrote on 8/12/2005 11:23 AM: \>\> TCL \<-\> Ruby:
> 
> --  
> Best regards, emailto: scholz at scriptolutions dot com  
> Lothar Scholz [http://www.ruby-ide.com](http://www.ruby-ide.com)  
> CTO Scriptolutions Ruby, PHP, Python IDE 's

---

<div class="post-metadata">

**Author:** ![Adrian\_Howard](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@Adrian\_Howard](https://rubytalk.org/u/Adrian_Howard)\
**Post date:** [12 August 2005 16:56 UTC](https://rubytalk.org/t/ruby-performance/20120/20 "2005-08-12T16:56:14Z")

</div>

[snip]

> \> - Perl 6 now! Many useful things that Perl 5 lacks and that Perl  
> \> 6 will give you like a decent built in OO system, classes as proper  
> \> objects, coroutines, simple block passing, etc. Ruby does now.
> 
> Yes thats also going to piss me off. I thought they got a few paid  
> full time worker on the language (at least one or two from  
> activestate). But i see almost no progress in Perl 6.

I do. Parrot is an interesting platform for dynamic languages that's just getting to a reasonable state, and Pugs is just /storming/ along. You can play with large chunks of Perl 6 now.

Cheers,

Adrian

> **···**
>
> On 12 Aug 2005, at 17:36, Lothar Scholz wrote:

[Next page](https://rubytalk.org/t/ruby-performance/20120.md?page=2)
