Hacker News new | ask | show | jobs
by AF 6762 days ago
The article is correct. In this interview (http://twit.tv/floss11) Guido states that Python has been OO from the outset (1990).

The thing you have to understand is Ruby and Python do OO differently. To Python everything is a hash table. This isn't the case for Ruby and their differences mainly stem from that. It adds interesting elements like functions are very simple to pass around in Python because they are not bound to a class. It is still OO, just a different way of doing it.

Guido has also repeated for years that passing around self isn't a technical necessity. He prefers it as part of Python's "explicit is better than implicit policy. What you have to understand is that a method call boils down to method(receiver, args...). Python just makes that explicit.

Another quote from Guido:

"Get rid of self: I think this has been addressed in the responses; it's not as easy as you'd think, and there are important advantages to the uniform interpretation of methods as "just functions that get called in a funky way". In Ruby, everything is a method, or an anonymous block, and there are no "free functions". Python uses the complimentary approach, treating functions as first-class citizens. Both approaches are complete; they are however incompatible, and you can't easily morph one into the other. (Personally, I find that the criticm of explicit self has about as much merit as the criticism of Python's use of whitespace.)" (http://www.artima.com/weblogs/viewpost.jsp?thread=214325)

I too think it is kind of a silly argument. Passing around self has never been a problem for me. 4 more letters for each method. Not a problem, imo, in exchange for first-class functions. And super() in Python works fairly similar to super in Ruby AFAIK.

For the record, Common Lisp users probably find both Python and Ruby's OO limited and clunky. Just got to keep in mind there's different ways of approaching it.

1 comments

No it isn't. "Both are strong object-oriented languages": the key word (that is wrong) is 'strong'. Based on my examples Python may implement OO better than say Perl but it is NOT a strong implementation of OO compared to other languages.

It's great to know how and why Python is the way it is, but at the end of the day you can give a million reasons, but the kettle will still be black.

What you posted is like me explaining that (current) Ruby is not slow (which is a joke), it just implements threading differently...

You can directly compare the speed of an application or a language.

It is not subjective to say 'C is faster than Perl' or 'Perl is faster than Ruby'. That is true, in almost every instance, C IS faster than the equivalent Perl code and the equivalent Perl code is faster than Ruby (whether that holds true for Ruby 1.9 we shall see).

On the other hand, what constitutes a 'strong' implementation of OO is purely subjective. Would you consider Common Lisp's implementation of OO 'strong'? It is completely different than how Ruby works. But it isn't any more or less OO, it is a different way of doing it. Now if we really want to get into subjectiveness, Smalltalkers would probably say that Ruby's OO is not 'strong' because Ruby resorts to not making conditionals actual objects, unlike Smalltalk, in which literally just about everything is an object.

You might even say that Python is more OO than Ruby because functions are objects in Python but methods are not similar first-class constructs in Ruby (note: I wouldn't actually argue this, but it is just an example of how the languages do something differently).

I still feel your 1st post was weak, but you make good points in this post - u win; i'm not keen on religious flame wars