Ted Leung on the air
Ted Leung on the air: Open Source, Java, Python, and ...
Ted Leung on the air: Open Source, Java, Python, and ...
Sat, 23 Aug 2003
Python and Ruby compared and contrasted
Lots of Python and Ruby comparisons out there:
Jim Weirich
observes that Pythonistas and Rubyists bring different assumptions to the table:
[01:04] |
[computers/programming/python] |
# |
TB |
F |
G |
2 Comments |
Python follows C++ and Java in using "." as a structure selector operation, while Ruby is more closely attuned to Smalltalk's message sending paradigm. Both approaches work and are interally consistent, but be prepared for surprises if you try to interpret one using the assumptions of the other.He also shows the result of his line noise calculator, which computes the number of line noise characters is a file. He ran this over equivalent C++, Java, Perl, Python, and Ruby code. It's instructive to see the programs laid out all in a row and see how much shorter the Python and Ruby programs are. I would like to see larger samples though, because I think that in larger Ruby programs, the line noise ratio increases. Jeffrey Shell blogs on Python's philisophy of simplicity and then references a comp.lang.python post that goes over his assessment of Ruby vs Python in great detail. In the blog post, he extols the Python module system and quotes Tim Peters' "The Zen of Python". The newsgroup post goes over the stuff in Ruby that is matched by Python 2.2. Hans Nowak has a series of 3 (so far) comparison posts. Here's some things I picked up:
- first post
- He sort of likes creative use of punctuation in Ruby. I'm the same. The use of ? and ! seem good to me.
- second post
-
Ruby yield works on closures.
Ruby can define methods on instances. - third
- He's not sure what the big deal is about procedure objects (closures). First classness.
Re: the line noise calculator:
From a Python programmer's standpoint, it's an easy step, when comparing the python and ruby Animal examples, to say that the superfluous "end" chars are line noise in the Ruby example, therefore putting Ruby way over Python for line noise :)
Posted by Richard Jones at Sun Aug 24 01:53:34 2003
From a Python programmer's standpoint, it's an easy step, when comparing the python and ruby Animal examples, to say that the superfluous "end" chars are line noise in the Ruby example, therefore putting Ruby way over Python for line noise :)
Posted by Richard Jones at Sun Aug 24 01:53:34 2003
Perhaps, but if you count that, you might also have to count Python's "self" in each of its method definitions, which I think goes back to Ruby "winning".
From what I've heard from a couple of Ruby programmers, the line noise characters are there in the language, but most people program without them, and so you might see a slightly larger proportion of line noise in larger programs, but it wouldn't be orders of magnitude larger by any means.
Posted by Blake Winton at Mon Aug 25 09:19:29 2003
From what I've heard from a couple of Ruby programmers, the line noise characters are there in the language, but most people program without them, and so you might see a slightly larger proportion of line noise in larger programs, but it wouldn't be orders of magnitude larger by any means.
Posted by Blake Winton at Mon Aug 25 09:19:29 2003
You can subscribe to an RSS feed of the comments for this blog:
Add a comment here:
You can use some HTML tags in the comment text:
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
<a href>
, <em>
, <i>
, <b>
, <blockquote>
, <br/>
, <p>
, <code>
, <pre>
, <cite>
, <sub>
and <sup>
.You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk