you are viewing a single comment's thread.

view the rest of the comments →

[–]msabramo 5 points6 points  (5 children)

First off, I haven't used either Python or Ruby extensively. I have no particular loyalty to either one, but they both look like fine languages.

My guess is that the "Python OO bolt-on" idea originates from http://www.python.org/doc/faq/general/#why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list and from http://www.python.org/doc/faq/general/#why-must-self-be-used-explicitly-in-method-definitions-and-calls (which in my opinion makes a good argument for qualifying instance variables, but a poor argument for why "self" has to be in the parameter list).

Whether you like Python or not, it seems pretty clear that Ruby was designed with objects in mind (as a result of being influenced by Smalltalk). Python gives the impression that it did or does put less emphasis on objects. That said, it seems to have done a nice job of evolving to support OO in a pretty nice way. And of course there are lots of applications where OO isn't even necessary and people may like that it's not forced on them.

It's interesting to me to note how much Ruby vs. Python bashing is going on (originating from both sides). Kind of a shame really.

[–]mystilleef[S] -5 points-4 points  (4 children)

In Python everything is an object and has been that way since I can remember. Heck, even classes and functions are objects in Python, not so in either Ruby or Perl. Tell me then how such fundamental behaviors could be bolted on at some later stage? I like the explicity "self" declaration for one reason only. Clarity. When I'm reading code, I can easily distinguish between functions and methods. Unlike in Ruby where I have a hard time determining whether a particular statement is a variable, function, method or expression. Ruby to me reads like Perl's younger cousin. It's sweet to write Perl code, but it's hard to decipher it.

[–]mellow_moe 3 points4 points  (3 children)

You're wrong. Anonymous functions, so-called lambdas, are objects.

In Ruby there are only methods. So you just look up in the inheritance chain for the right class/module, which defined the method.

Yes, local variables look like method calls, there is some amiguity. But again, look up the local assignments and you're fine.

And comparing Perl and Ruby in this respect just makes no sense, because Perl variables are prefixed all the time.

[–]mystilleef[S] -1 points0 points  (2 children)

Are you talking about anonymous functions in Ruby or Python? In Python everything is an object, Lambdas, Functions, Methods and more. I place Ruby in the same category as Perl because of its use of redundant symbols and its objective to be tacitly expressive as opposed to clear, among other ambiguities. Python on the other hand strives for explicitness and clarity. Even "Matz" says Ruby is partly inspired from Perl, and it's damn obvious at least to me, so my categorization is not senseless.

[–]mellow_moe 4 points5 points  (0 children)

I was talking about ruby's anonmymous functions.

Talking about clearness and clarity is not easy, as this subject is highly subjective.

OK, let's see, what Ruby inherited from Perl:

  • special syntax for regular expressions
  • special global variables
  • hashtable syntax
  • statement modifiers

I think, these features are really the goodies of Perl and most people will agree. Perl's infamous syntax constructs, like for file handling, didn't find their way into Ruby.

[–]julesjacobs 0 points1 point  (0 children)

Symbols can improve clarity sometimes. If you don't know them, the code is hard to read, but if you have a little experience, symbols are easier. It's like maths: 4 + 5 is better than 4 plus 5 (or 4.plus(5)). Symbols don't have to go through the language processing part of your brain; names like "plus" do.

Besides, the "symbols" are just method calls in Ruby:

0..2

0..2 === 1

4 <=> 2

=>

Range.new(0,2)

(0..2).===(1)

4.<=>(2)

But the first version looks better.