Li Chen wrote:
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?
Another poster has given you the answer, but I am curious about why you
would think that an object-oriented environment would necessarily be
than one that doesn’t have this orientation.
It seems obvious to me that the structure required to suppport an OO
environment does so by sacrificing speed. This relationship is borne out
most OO languages to date. The advantage in adopting OO programming
are obvious, but execution speed just isn’t on the list.
At this point, someone might ask what is the point, then? Why have
The answer is that some programming problems are sufficiently complex
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.
Another way of saying this is an unwritable computer program has a very
The proofs of this are all around us. The best example is Windows, which
represents a pastiche of different methods for writing software over
years, most of them not remotely structured or object-oriented. The
is that Microsoft simply cannot control the code base or reshape it to
new requirements, notwithstanding the fantastic profits that would
if certain goals were to be achieved. Microsoft has recently had to
give up on certain goals because the code base is in such a sorry state.
Under these circumstances, the code’s execution speed would seem to be a