From: Paul Lutus Date: 2006-10-21T08:40:13+09:00 Subject: Re: Ruby and Perl Li Chen wrote: > 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? 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. It seems obvious to me that the structure required to suppport an OO environment does so by sacrificing speed. This relationship is borne out in most OO languages to date. The advantage in adopting OO programming methods are obvious, but execution speed just isn't on the list. 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. Another way of saying this is an unwritable computer program has a very slow execution speed. The proofs of this are all around us. The best example is Windows, which represents a pastiche of different methods for writing software over many years, most of them not remotely structured or object-oriented. The result is that Microsoft simply cannot control the code base or reshape it to meet new requirements, notwithstanding the fantastic profits that would accrue if certain goals were to be achieved. Microsoft has recently had to simply 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 secondary consideration. -- Paul Lutus http://www.arachnoid.com