Matz, who invented Ruby, said that he designed the language to be more object-oriented than Python. How is Ruby more object-oriented than Python?
One example that's commonly given is len
, which in Python is a built-in function. You may implement a special __len__
method in your objects which will be called by len
, but len
is still a function. In Ruby, objects just have the .length
property/method so it appears more object oriented when you say obj.length
rather than len(obj)
although deep under the hood pretty much the same thing happens.
That said, over the years Python have moved towards more object-orientation. Currently all objects (and implicitly user-defined objects) inherit from the object
class. Meta-classes have also been added, and many of the built-in and core library classes have been organized into hierarchies with the help of ABCs (Abstract Base Classes).
In my heavy usage of Python I have never found it lacking in the OO department. It can do everything I want it to do with objects. True, Ruby feels somewhat more purely OO, but at least in my experience this hasn't been a really practical concern.
If you take the Python from 1993 and compare it with Ruby then the later is more object oriented. However, after the overhaul in Python 2.2 this is no longer true. I would say that modern Python is as object oriented as it gets.
It's simple, nearly everything in Ruby (including numbers) is an object; there are no scalar values.