Can somebody give me an advice about what to learn?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Oct 4 02:34:42 EDT 2012


On Wed, 03 Oct 2012 21:47:33 -0700, Chris Rebert wrote:

> On Wed, Oct 3, 2012 at 11:31 AM, Wolfgang Keller <feliphil at gmx.net>
> wrote:
>>> I'm really new to Usenet/Newsgroups, but... I'd like to learn some new
>>> programming language, because I learnt a bit of Perl though its OOP is
>>> ugly. So, after searching a bit, I found Python and Ruby, and both of
>>> they are cute. So, assuming you'll say me "learn python", why should I
>>> learn it over Ruby?
>>
>> The point why Ruby was started (perceived deficit of
>> object-orientation) has been remedied since Python 2.2.
> 
> Not completely. At the least, there's arguably still the issue of len()
> and friends (vs. `.length` etc.), and also of `self` being explicit.

I'm not entirely sure which "perceived deficit of object-orientation" is 
being talked about, or why anyone but OOP purists would consider that a 
problem.

Python is *more* object-oriented than Java, and I don't hear anyone 
complaining that Java isn't object-oriented. Everything[1] in Python is 
an object. *Everything*. Ints are objects. Strings are objects. Arrays 
are objects. There's no distinction between "boxed" and "unboxed" ints, 
like in Java or Haskell -- Python just has ints, and they're always 
objects.

As for len() and friends, that's a red-herring. Just because the syntax 
is written len(x) instead of x.len() doesn't make Python less object-
oriented. It's just syntax: "a + b" is no less OO than "a.plus(b)".

Somebody might not *like* the syntax "a + b", or "len(x)", but they 
should just say so, and not pretend that it isn't OO.

Likewise self. Explicit or implicit, how does that make a language less 
or more object-oriented? That's as foolish as saying that Python isn't 
object-oriented because you don't have to declare the type of variables:

x = (float)1.234

Again, there are arguments for and against explicit self, but "explicit 
self is not OO" is not a valid argument.

Being object-oriented has both costs and benefits. Java compromises on 
the idea of OOP for performance: native, non-object ints are faster than 
object ints. All these people complaining that Python isn't OO enough 
because you have to write "self" in method declarations, why aren't they 
complaining that Java isn't OO enough because ints are unboxed primitive 
types?



[1] Emphasis on the *thing* part. Control structures aren't things in 
that sense, they aren't values at all, they are actions that takes place 
during execution.


-- 
Steven



More information about the Python-list mailing list