Ruby and Perl

L

Li Chen

Hi guys,

I teach myself some Perl before I change to Ruby. I am just curious: If
I use the same algorithm to write a Perl and Ruby script, respectively,
which one will run faster? Since everyting in Ruby is object or
reference to an object the script written by Ruby should run faster than
that in Perl's.
Am I right?

Any comments?

Thanks,

Li
 
K

khaines

Hi guys,

I teach myself some Perl before I change to Ruby. I am just curious: If
I use the same algorithm to write a Perl and Ruby script, respectively,
which one will run faster? Since everyting in Ruby is object or
reference to an object the script written by Ruby should run faster than
that in Perl's.
Am I right?

No.

If you're looking for a general trend, the trend will be that the Ruby
code will maybe be shorter (if you try to write readable Perl instead of
line noise Perl, it'll be shorter), it will be far more readable, and
it'll run more slowly.

There are exceptions, but that will be the observed trend.


Kirk Haines
 
S

Squeamizh

Paul said:
At this point, someone might ask what is the point, then? Why have objects?
The answer is that some programming problems are sufficiently complex that
either it is not possible to write a reliable program without using OO
principles, or a particular program can't be written at all using
conventional, pre-OO methods.

Such as... ?
 
A

Adrian Howard

Another poster has given you the answer, but I am curious about why
you
would think that an object-oriented environment would necessarily
be faster
than one that doesn't have this orientation.
[snip]

Because some of us have used Eiffel, Smalltalk and Lisp
implementations that are pretty darn speedy :) Hell OO Perl is
speedier than Ruby last time I benchmarked.

Not that I dislike Ruby. It's fast enough for me, and the decrease in
developer time more than make up for any decrease in execution speed.
That doesn't mean that Ruby's speed (or lack thereof) is down to it's
OO orientation - or that it can't improve (YARV for example).

Cheers,

Adrian
 
P

Paul Lynch

1. The next version of Windows, the one that Microsoft had intended to
write, but gave up on, in spite of the billions of dollars in
potential
profits. Part of the reason is the well-documented cowboy coder
culture at
Microsoft, and part of it results from the poorly structured code in
present-day Windows.

2. The crime statistic database that the FBI would love to write,
spent
US$170 million dollars trying to write, but failed to write.

3. The replacement code for the FAA's traffic control system, which
they
spent many millions developing, only to give up on and revert to
their old
code and machines.

Many similar stories. Dozens.

Obviously when I say that such a program can't be written without
using OO
methods, this is a bit hyperbolic, since these are all examples of
programs
that can be written in principle, but with budget and time
constraints, it
is often not possible in practice.

Add to that virtually any government funded large project.

However, I suspect that the poster was looking for examples of
projects that had failed by non-OO methods, but succeeded with OO.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top