From: Jason Creighton Date: 2003-09-17T03:52:03+09:00 Subject: Re: performance and style advice requested On Tue, 16 Sep 2003 07:40:34 +0900 Ben Giddings wrote: > (In another post) Alex Martelli wrote: > >> While I doubt you should compare these languages on performance merits > > *blink* why not, pray? While clarity, productivity, simplicity, and so on, > > are surely all crucial attributes in a language, what's wrong with wanting > > to ascertain how it performs (when used in the best/fastest way, at least) > > in typical problems in one's domains of interest...? > > I don't think that it's wrong to compare the speed of the languages. I > just wouldn't be surprised if Python is faster by a healthy margin, > especially for a very simple numerical program like this. In Ruby, > *everything* is an object, including numbers. This has certain > advantages, but definitely carries some speed penalties. Err...isn't everything an object in Python as well? ~$ python Python 2.3 (#1, Aug 4 2003, 08:45:40) [GCC 3.2.2 (CRUX)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> n = 5.5 >>> dir(n) ['__abs__', '__add__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__getattribute__', '__getnewargs__', '__hash__', '__init__', '__int__', '__long__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__pos__', '__pow__', '__radd__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmod__', '__rmul__', '__rpow__', '__rsub__', '__rtruediv__', '__setattr__', '__str__', '__sub__', '__truediv__'] >>> n.__add__(4) 9.5 >>> n.__int__() 5 > By using a scripting language rather than assembly or C, you've already > decided you're willing to sacrifice some performance for ease of use. I > expect that both Perl and Python would beat Ruby in nearly any > benchmark, but I find Ruby much easier to use than both. For tasks > where a scripting language is appropriate, I choose Ruby. Yes, I have found that both Perl and Python seem to be faster than Ruby for running the code, but Ruby is faster for writing it. :) Jason Creighton