I don't like the OO part of python. In particular the "self" keyword everywhere.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

Skybuck Flying-2
Hello,

I don't like the object orientated part of Python.

The idea/prospect of having to write "self" everywhere... seems very
horrorific and a huge time waster.

(Perhaps the module thing of python might help in future not sure about
that).

What are your thoughts on the "self" thing/requirement.

I only want replies from expert programmers, cause we need a language for
expert programmers...

Not noobies that need to be hand-held...

Personally I think I could do just fine with the "self" keyword everywhere.

So question is... can the python interpreter/compiler be written in such a
way that self can be left out ?

In other words: Is there any hope... that this part of the language will be
cleaned up some day ?

Are there any tricks to get rid of it ?

Maybe "white" like in Delphi ?

I haven't written much OO code yet in Python... and don't plan on doing it
too...

Cause it looks hellish confusing... and clouded/clodded.

I think I have better things to do then to insert "self" everywhere...

It's almost like "self" masturbation  LOL.

Bye,
  Skybuck =D


Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

Skybuck Flying-2
Then again...

I also believe the highest goal for a programming language is "natural
spoken" language.

If "self.somefield" equals 10 then...

Does have some understandable ring to it.

However... time constraints also have to be kept in mind.

In another words if the code looks like

begin of class section

if somefield equals 10 then...


end of class section

Should be pretty obvious that somefield belongs to class section...

So no need to specify self...

If I wanted to access a global variable I would use the existing "global"
thing

global SomeField...

maybe if I wanted to use a local variable for routine:

local SomeField...

seems nicer... then having to use self everywhere...

Bye,
  Skybuck.


Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

Chris Angelico
On Thu, Jun 11, 2015 at 9:27 PM, Skybuck Flying <skybuck2000 at hotmail.com> wrote:

> If I wanted to access a global variable I would use the existing "global"
> thing
>
> global SomeField...
>
> maybe if I wanted to use a local variable for routine:
>
> local SomeField...
>
> seems nicer... then having to use self everywhere...

Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

Chris Angelico
In reply to this post by Skybuck Flying-2
On Thu, Jun 11, 2015 at 9:27 PM, Skybuck Flying <skybuck2000 at hotmail.com> wrote:

> If I wanted to access a global variable I would use the existing "global"
> thing
>
> global SomeField...
>
> maybe if I wanted to use a local variable for routine:
>
> local SomeField...
>
> seems nicer... then having to use self everywhere...

Oops, missent.

If you want this, how about simply declaring all function-local
variables, and having everything else be implicitly global? Or declare
(with data type) all globals, all class attributes, and all locals,
and then let the compiler figure out what you want? Because if you
want ECMAScript or C++, you know where to find them.

ChrisA

Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

MRAB-2
In reply to this post by Skybuck Flying-2
On 2015-06-11 12:27, Skybuck Flying wrote:
> Then again...
>
> I also believe the highest goal for a programming language is "natural
> spoken" language.
>
Natural language is full of ambiguities.

> If "self.somefield" equals 10 then...
>
> Does have some understandable ring to it.
>
> However... time constraints also have to be kept in mind.
>
> In another words if the code looks like
>
> begin of class section
>
Shouldn't that be "beginning of class section"?

> if somefield equals 10 then...
>
>
> end of class section
>
You should have a look at Cobol. If was designed with a more natural-
looking syntax so that business managers could write their own code.

It turned out that the managers didn't write code because programming
harder then they anticipated.

Then there's AppleScript. It also tries to have a more natural-looking
syntax, but the problem is that it's then not so clear what's legal.
For example, it allows "title of window" or "window's title". So what
is the title of the script's title? It's "title of window of me" or
"me's window's title". Yes, "me's", not "my". It's an example of the
"Uncanny Valley".

I prefer a language that doesn't look like a natural language, because
it isn't, that's not its purpose.

> Should be pretty obvious that somefield belongs to class section...
>
> So no need to specify self...
>
> If I wanted to access a global variable I would use the existing "global"
> thing
>
> global SomeField...
>
> maybe if I wanted to use a local variable for routine:
>
> local SomeField...
>
> seems nicer... then having to use self everywhere...
>
"then"? Should be "than"... (That seems to be happening more and more
these days...)

Anyway, the use of "self" is something that's not going to change.

If you don't like it, there are plenty of other programming languages
out there for you to try.


Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

Michael Torrie
In reply to this post by Skybuck Flying-2
On 06/11/2015 05:19 AM, Skybuck Flying wrote:
> I haven't written much OO code yet in Python... and don't plan on doing it
> too...

Except that you already have written OO code in Python with your parser.
 Or at least code that interacts heavily with OO.  Anytime you call a
method on a string like split(), or worked with regular expressions, you
are using OO.  OO permeates Python.  You don't have to use OO design in
your programs, but you will always be working with objects and calling
methods on them.

But anyway, if you don't like "self," use a different name.  Like "skybuck."

class Bar:
    def foo(skybuck, a, b):
        skybuck.a = a
        skybuck.b = b

In other languages with an implicit self or this like C, I find the
ambiguities of scope highly problematic.  Method variables can shadow
instance variables.  It's also difficult for someone unfamiliar with the
code to differentiate between a local variable and an instance variable
as the naked variable name has no qualifier.  I've seen some projects
that apply a "m_" prefix to every instance variable so you can tell them
apart.  Sure that's less typing, but it is super ugly!  Explicitly
providing self not only makes things very clear, it also helps me when
I'm scrolling through code to identify which functions definitions are
bare functions and which are methods of a class.

In short, it's part of the Python language and will not be changing
anytime soon.  So no the interpreter couldn't be written in such a way
that the self can be left out without changing the language's semantics
and definition.


Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

Thomas Mlynarczyk
In reply to this post by Skybuck Flying-2
On 11/06/15 14:16, MRAB wrote:
> harder then they anticipated.
-----------^
>> seems nicer... then having to use self everywhere...
>>
> "then"? Should be "than"... (That seems to be happening more and more
> these days...)

Indeed :-)

--
Ce n'est pas parce qu'ils sont nombreux ? avoir tort qu'ils ont raison!
(Coluche)

Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

Rustom Mody
In reply to this post by Skybuck Flying-2
On Thursday, June 11, 2015 at 4:49:59 PM UTC+5:30, Skybuck Flying wrote:

> Hello,
>
> I don't like the object orientated part of Python.
>
> The idea/prospect of having to write "self" everywhere... seems very
> horrorific and a huge time waster.
>
> (Perhaps the module thing of python might help in future not sure about
> that).
>
> What are your thoughts on the "self" thing/requirement.
>
> I only want replies from expert programmers, cause we need a language for
> expert programmers...
>
> Not noobies that need to be hand-held...
>
> Personally I think I could do just fine with the "self" keyword everywhere.
>
> So question is... can the python interpreter/compiler be written in such a
> way that self can be left out ?
>
> In other words: Is there any hope... that this part of the language will be
> cleaned up some day ?
>
> Are there any tricks to get rid of it ?
>
> Maybe "white" like in Delphi ?
>
> I haven't written much OO code yet in Python... and don't plan on doing it
> too...
>
> Cause it looks hellish confusing... and clouded/clodded.
>
> I think I have better things to do then to insert "self" everywhere...
>
> It's almost like "self" masturbation  LOL.
>
> Bye,
>   Skybuck =D

I suggest you disentangle your question/crib along 3 axes:

1. Specific grumble about a specific feature -- in this case 'explicit-self'
2. General discomfort with a style/paradigm -- OO

2 itself can be bifurcated along 2 axes
2a. Hard when learning
2b. Painful/stupid for serious/real-world usage

That 2a and 2b were quite separate was well understood in the 70s and
80s when Pascal was widely known.  Today it seems increasingly
forgotten.  eg all the OOP texts that I studied wax endlessly
on circles and ellipses and rectangles and squares and other such
wonders of God's (or OO's) creations.
Today http://en.wikipedia.org/wiki/Circle-ellipse_problem suggests its not
so neat (or useful) as the OO aficionados imagine


Reply | Threaded
Open this post in threaded view
|

I don't like the OO part of python. In particular the "self" keyword everywhere.

sohcahtoa82@gmail.com
In reply to this post by Skybuck Flying-2
On Thursday, June 11, 2015 at 4:19:59 AM UTC-7, Skybuck Flying wrote:

> Hello,
>
> I don't like the object orientated part of Python.
>
> The idea/prospect of having to write "self" everywhere... seems very
> horrorific and a huge time waster.
>
> (Perhaps the module thing of python might help in future not sure about
> that).
>
> What are your thoughts on the "self" thing/requirement.
>
> I only want replies from expert programmers, cause we need a language for
> expert programmers...
>
> Not noobies that need to be hand-held...
>
> Personally I think I could do just fine with the "self" keyword everywhere.
>
> So question is... can the python interpreter/compiler be written in such a
> way that self can be left out ?
>
> In other words: Is there any hope... that this part of the language will be
> cleaned up some day ?
>
> Are there any tricks to get rid of it ?
>
> Maybe "white" like in Delphi ?
>
> I haven't written much OO code yet in Python... and don't plan on doing it
> too...
>
> Cause it looks hellish confusing... and clouded/clodded.
>
> I think I have better things to do then to insert "self" everywhere...
>
> It's almost like "self" masturbation  LOL.
>
> Bye,
>   Skybuck =D

We just had a huge thread about the "self" thing less than two weeks ago.