M
Max Cantor
I have a question about the difference(s) between Python and Ruby. I
have been working with both languages for about one year each now, and I
keep finding differences that turn out to be just syntactical. I will
elaborate, but this is the gist of my question:
What can Python do that Ruby can't? What can Ruby do that Python can't?
What does Ruby gain from its syntactic quirks, other than easier DSL
implementation?
I recognize that this is potentially a very "religious" question, so I'd
like to specifically note that I'm not talking about whether one
language is "better" or faster or easier to use. I'm just trying to
grok the real differences between Ruby and Python, and the reasons
behind the design decisions that created them as they are today.
For my comments below, please refer to the attached rar.
One example: A simple Python closure technique can be seen in clos.py.
This leverages Python's simple first-class function support. However,
with very little effort, we can replicate the technique in clos.rb with
a lambda and the call() method.
Conversely, we can look at a good usage of Ruby's block/yield
functionality in iter.rb. Again, with only a little bit of
head-scratching, we can translate this rather directly to Python using
UserList and, again, Python's first-class function capabilities.
Even in terms of real closures, like the example in clos2.rb and
clos2.py, which I shamelessly stole from Google, Ruby and Python fail to
really outpace each other.
So, how do blocks in Ruby REALLY differ from lambdas in Python? Is
there anything you can do in one language that some fancy footwork can't
achieve in the other, or is that the point of their differences? I know
all of the knee-jerk reactions: Multiple inheritance, syntactical
indentation, keyword arguments, regex literals... those are all either
matters of taste or easily simulated. What are the "real" differences,
if any? Was Matz's intention in creating Ruby to approach existing
functionality with a new syntax, or are there things I'm not seeing?
Thanks so much in advance for all of your thoughts and comments. I'm
looking forward to seeing what everyone says, and solving this mystery!
Attachments:
http://www.ruby-forum.com/attachment/1872/rbpy.rar
have been working with both languages for about one year each now, and I
keep finding differences that turn out to be just syntactical. I will
elaborate, but this is the gist of my question:
What can Python do that Ruby can't? What can Ruby do that Python can't?
What does Ruby gain from its syntactic quirks, other than easier DSL
implementation?
I recognize that this is potentially a very "religious" question, so I'd
like to specifically note that I'm not talking about whether one
language is "better" or faster or easier to use. I'm just trying to
grok the real differences between Ruby and Python, and the reasons
behind the design decisions that created them as they are today.
For my comments below, please refer to the attached rar.
One example: A simple Python closure technique can be seen in clos.py.
This leverages Python's simple first-class function support. However,
with very little effort, we can replicate the technique in clos.rb with
a lambda and the call() method.
Conversely, we can look at a good usage of Ruby's block/yield
functionality in iter.rb. Again, with only a little bit of
head-scratching, we can translate this rather directly to Python using
UserList and, again, Python's first-class function capabilities.
Even in terms of real closures, like the example in clos2.rb and
clos2.py, which I shamelessly stole from Google, Ruby and Python fail to
really outpace each other.
So, how do blocks in Ruby REALLY differ from lambdas in Python? Is
there anything you can do in one language that some fancy footwork can't
achieve in the other, or is that the point of their differences? I know
all of the knee-jerk reactions: Multiple inheritance, syntactical
indentation, keyword arguments, regex literals... those are all either
matters of taste or easily simulated. What are the "real" differences,
if any? Was Matz's intention in creating Ruby to approach existing
functionality with a new syntax, or are there things I'm not seeing?
Thanks so much in advance for all of your thoughts and comments. I'm
looking forward to seeing what everyone says, and solving this mystery!
Attachments:
http://www.ruby-forum.com/attachment/1872/rbpy.rar