[BangPypers] Object Oriented Programming in python

Saager Mhatre saager.mhatre at gmail.com
Mon Oct 21 07:25:15 CEST 2013


On Oct 18, 2013 10:54 AM, "s|s" <supr.e.etsethi at gmail.com> wrote:
>
> Hi Pranav,
>
> I would pose a counter question regarding object oriented programming.
How did you learn OOP concepts? I am assuming like most of us, probably
through a C++ or Java course. These courses ingrain a certain expectation
of what OOP should "look like". Which to me seems to be a dis-service to
underpinnings of Object Oriented Paradigm itself.
>

I think it's a little unfair to club C++ and Java in the same bucket just
because one borrows some syntactic elements from the other in order to
maintain a smooth migration path.

> Python implements OOP differently from imperative languages of C family
like C++ and Java.

Umm... I don't know if anyone's told you yet, but Python is also
essentially an imperative programming language.

> The reason, I think is C++ and Java are very much driven towards machine
code efficiency whereas Python is very much about developers productive.

You couldn't be far from the truth. While, syntactically, Python is touted
to be more reader-friendly, that was also one of the design goals of Java.
Just because a bunch of people write bad Java code doesn't mean that the
language leans toward low-level optimizations; I've seen enough atrocious
Python code in my 2.5 years working with it that has obliterated any notion
of readability/productivity. And anyone suggesting LOC comparisons better
be prepared for some righteous Monty Pythonic Trout Slapping!

Also, comparing a dynamically typed language to two statically typed
languages is hardly fair. A comparison to other dynamically typed,
imperative languages like Groovy, Ruby or SmallTalk would be more useful;
all of which, BTW, provide primitives for the kind of encapsulation the OP
is looking for.

> To this end Python developers must have thought of data hiding as not an
important language goal.
>

That makes no sense. Implementing the notion of  encapsulation doesn't
particularly get in the way of developer productivity. If anything, it
enhances productivity by providing compiler/interpreter hints that
communicate when developers are engaging in undesirable resource access.

> Mind you Python does allow data hiding through slots but it is not as
straight forward as C++ or Java.
>

Sigh! Implementing a reasonably important feature in an obscure manner
(that too, not completely, since even slots are accessible from outside an
object) is not in keeping with friendliness. I say this feature is
reasonably important since it is repeatedly brought up every few months
with little to no satisfactory responses most of which is 'we are all
adults here', which I am hard pressed to accept as a generalization on
account of all the atrocious code mentioned above.

- d


More information about the BangPypers mailing list