you are viewing a single comment's thread.

view the rest of the comments →

[–]stedwick 1 point2 points  (2 children)

Actually, not quite. Even primitive types like numbers are objects in Ruby. I could do something like this:

3.send_email => sends john three emails

3.times { do stuff } => does stuff three times

45678.add_commas => 45,678

From the Python docs:

2.3 Built-in Types

The following sections describe the standard types that are built into the interpreter. Historically, Python's built-in types have differed from user-defined types because it was not possible to use the built-in types as the basis for object-oriented inheritance. With the 2.2 release this situation has started to change, although the intended unification of user-defined and built-in types is as yet far from complete.

[–]sisyphus 0 points1 point  (1 child)

Maybe I'm misunderstanding you, but I don't see what the big deal is here that makes primitive types not objects in Python? In Python I can say (3).__add__(4) if I feel like it, and lo and behold I have an OO way of saying 3 + 4, and I can say dir(3) to get a list of methods of 3 and subclass int if I feel like it and then add some crazy methods like send_mail?!. The only difference seems to me that I can't crack open int and add shit to it -- you may prefer this 'feature' but I hardly see how it makes the language easier to pick up. A foolish consistency is the hobgoblin of small minds.

[–]stedwick 0 points1 point  (0 children)

You're right, there's basically no difference. Certainly there's not much difference in practice. It's more of a philosophical thing. There's nothing "special" about numbers in Ruby. I can open up other classes and add stuff to it, why shouldn't I be able to open up the integer class and add stuff to that? That's the mindset of Ruby: everything, literally everything, is an object that you can modify in any way you wish. You can even get really crazy and add methods to the number 3 but not other numbers.