Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29543 > unrolled thread

Newbie trying to understand object oriented programming

Started bybit-naughty@hotmail.com
First post2016-02-05 06:55 -0800
Last post2016-02-06 11:56 -0200
Articles 20 on this page of 46 — 14 participants

Back to article view | Back to comp.lang.javascript


Contents

  Newbie trying to understand object oriented programming bit-naughty@hotmail.com - 2016-02-05 06:55 -0800
    Re: Newbie trying to understand object oriented programming 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-05 18:56 +0000
    Re: Newbie trying to understand object oriented programming Tim Slattery <tim@risingdove.com> - 2016-02-05 14:07 -0500
    Re: Newbie trying to understand object oriented programming Aleksandro <aleksandro@gmx.com> - 2016-02-05 17:34 -0300
      Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-05 19:10 -0800
        Re: Newbie trying to understand object oriented programming 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-06 08:33 +0000
          Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-06 08:24 -0800
            Re: Newbie trying to understand object oriented programming 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-06 18:48 +0000
              Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-06 12:28 -0800
                Re: Newbie trying to understand object oriented programming 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-06 21:01 +0000
                  Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-07 15:23 -0800
                    Re: Newbie trying to understand object oriented programming Aleksandro <aleksandro@gmx.com> - 2016-02-08 11:45 -0300
              Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-08 13:39 -0800
                Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-11 08:09 -0800
                  Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-11 12:22 -0800
                    Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-12 11:09 +0000
                      Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-12 13:34 -0800
                        Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-13 14:40 +0000
                          Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-14 10:18 -0800
                            Re: Newbie trying to understand object oriented programming Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-14 21:27 +0100
                            Re: Newbie trying to understand object oriented programming "J. Clarke" <j.clarke.873638@gmail.com> - 2016-05-14 10:13 -0400
                              Re: Newbie trying to understand object oriented programming Tim Streater <timstreater@greenbee.net> - 2016-05-14 16:47 +0100
                                Re: Newbie trying to understand object oriented programming "J. Clarke" <j.clarke.873638@gmail.com> - 2016-05-15 07:05 -0400
                              Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-14 10:08 -0700
                                Re: Newbie trying to understand object oriented programming "J. Clarke" <j.clarke.873638@gmail.com> - 2016-05-15 07:02 -0400
                                  Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-15 13:11 -0700
                              Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-05-15 17:03 +0100
                                Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-15 13:20 -0700
                                Re: Newbie trying to understand object oriented programming Gene Wirchenko <genew@telus.net> - 2016-05-16 11:55 -0700
                            Re: Newbie trying to understand object oriented programming Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-16 21:39 +0200
                              Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-17 07:30 -0700
                              Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-05-17 15:34 +0100
                        Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-13 17:50 -0800
                          Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-14 11:15 +0000
                          Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-14 11:03 -0800
                            Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-15 20:18 +0000
                    Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-13 16:54 -0800
    Re: Newbie trying to understand object oriented programming Danny <dann90038@gmail.com> - 2016-02-05 15:00 -0800
    Re: Newbie trying to understand object oriented programming RobG <rgqld@iinet.net.au> - 2016-02-06 17:18 +1000
      Re: Newbie trying to understand object oriented programming Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-06 16:01 +0100
      Re: Newbie trying to understand object oriented programming bit-naughty@hotmail.com - 2016-02-07 04:47 -0800
        Re: Newbie trying to understand object oriented programming Tim Streater <timstreater@greenbee.net> - 2016-02-07 13:16 +0000
        Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-07 17:29 +0000
          Re: Newbie trying to understand object oriented programming bit-naughty@hotmail.com - 2016-02-08 08:53 -0800
            Re: Newbie trying to understand object oriented programming Tim Streater <timstreater@greenbee.net> - 2016-02-08 17:33 +0000
    Re: Newbie trying to understand object oriented programming Joao Rodrigues <jr@none.com> - 2016-02-06 11:56 -0200

Page 1 of 3  [1] 2 3  Next page →


#29543 — Newbie trying to understand object oriented programming

Frombit-naughty@hotmail.com
Date2016-02-05 06:55 -0800
SubjectNewbie trying to understand object oriented programming
Message-ID<664696a0-3ce3-484c-aeaf-2fdf45781bb4@googlegroups.com>
Hi,
OK, I've read about and tried to understand OOP for a long time now, but I don't think I really get it.
This question just popped into my head while mulling the whole thing over:

"this" means *that one*, right? Like, it's a cookie cutter.....?

Then what about this?:

if I have:

function vegetables() {
this.colour="brown";
}

and I do both a
var potatoes = new vegetables() ;

AND a 
var tomatoes = new vegetables();


Then BOTH potatoes.colour will be "brown" *AND* tomatoes.colour will be "brown", right.....??!!!

This doesn't sound right......? Where is my reasoning flawed? Where am I screwing up? This doesn't sound like "this" means *that one*.....?



Thanks for your help.

[toc] | [next] | [standalone]


#29549

From4ndre4 <4ndre4@4ndre4.com.invalid>
Date2016-02-05 18:56 +0000
Message-ID<n92r3s$fkr$1@dont-email.me>
In reply to#29543
On 05/02/2016 14:55, bit-naughty@hotmail.com wrote:

[...]
> OK, I've read about and tried to understand OOP for a long time now, but I don't think I really get it.
>
> "this" means *that one*, right? Like, it's a cookie cutter.....?

https://en.wikipedia.org/wiki/This_(computer_programming)

-- 
4ndre4
"The use of COBOL cripples the mind; its teaching should, therefore, be 
regarded as a criminal offense." (E. Dijkstra)
"Ora, questo "Delta11" non è nulla di più di uno scemo del villaggio" - 
http://goo.gl/1nrkkX

[toc] | [prev] | [next] | [standalone]


#29550

FromTim Slattery <tim@risingdove.com>
Date2016-02-05 14:07 -0500
Message-ID<4hs9bbpqjgequ4bg6frtfd7ukl1shbtfab@4ax.com>
In reply to#29543
bit-naughty@hotmail.com wrote:

>function vegetables() {
>this.colour="brown";
>}
>
>and I do both a
>var potatoes = new vegetables() ;
>
>AND a 
>var tomatoes = new vegetables();
>
>
>Then BOTH potatoes.colour will be "brown" *AND* tomatoes.colour will be "brown", right.....??!!!
>
>This doesn't sound right......? Where is my reasoning flawed? 

Not all vegetables are brown, so why does your constructor make them
all brown? The constructor should initialize things that are common to
*all* vegetables. Individual instantiations should set properties that
are unique to themselves.

-- 
Tim Slattery
tim <at> risingdove <dot> com

[toc] | [prev] | [next] | [standalone]


#29551

FromAleksandro <aleksandro@gmx.com>
Date2016-02-05 17:34 -0300
Message-ID<n930rb$9u2$1@dont-email.me>
In reply to#29543
On 05/02/16 11:55, bit-naughty@hotmail.com wrote:
> Hi,
> OK, I've read about and tried to understand OOP for a long time now, but I don't think I really get it.

I think that trying to understand OOP with Javascript's prototype-based
method to make them is not a really good idea. I suggest you first learn
C++'s.

[toc] | [prev] | [next] | [standalone]


#29553

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-02-05 19:10 -0800
Message-ID<6d2bf8a5-4f8e-47f3-bd56-137aaeaa3028@googlegroups.com>
In reply to#29551
Aleksandro wrote:
> bit-naughty@hotmail.com wrote:

>> OK, I've read about and tried to understand OOP for a long time now, 
>> but I don't think I really get it.

> I think that trying to understand OOP with Javascript's prototype-based
> method to make them is not a really good idea. I suggest you first learn
> C++'s.

I disagree.  I would suggest that C++/Java/C# are among the *worst* 
ways to learn OOP.  Smalltalk would be better.  Python or perhaps Ruby 
might be acceptable, but more unusual OOP styles like Self or 
Javascript would also teach a fair bit, as would a language that never 
really claims to be object-oriented, but contains some of the best OOP 
ideas: Erlang.

Of course, I'd suggest that learning functional programming is more 
interesting still, and there's a whole herd of languages that support 
FP.  That list intersects with the OOP world in at least Javascript, 
Scala, LISP (if LISP can be considered to match any of these 
paradigms, when really it simply invented them and mixes and matches 
them as it pleases :-) ), and, with the same caveats, Erlang.  Many 
other languages straddle the line a bit differently, falling mostly 
into one camp, but with enough support for the other to be able to 
claim some degree of membership.

But still, C++ to teach OOP?  In 2016?  I think there are many better
choices.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#29557

From4ndre4 <4ndre4@4ndre4.com.invalid>
Date2016-02-06 08:33 +0000
Message-ID<n94av5$rgc$1@dont-email.me>
In reply to#29553
On 06/02/2016 03:10, Scott Sauyet wrote:

[...]
> I disagree.  I would suggest that C++/Java/C# are among the *worst*
> ways to learn OOP.

I wouldn't suggest C++ either because, with the latest additions of 
C++11 and C++14 (and the C++17 to come), the language has become much 
more complex and can be confusing for a newsbie. Java and C# are good 
choices to learn OOP though. The classic three tenets of OOP, 
encapsulation, inheritance and polimorphism, are implemented by both 
languages.

-- 
4ndre4
"The use of COBOL cripples the mind; its teaching should, therefore, be 
regarded as a criminal offense." (E. Dijkstra)

[toc] | [prev] | [next] | [standalone]


#29563

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-02-06 08:24 -0800
Message-ID<133d1da1-0767-42b4-80c3-922e40ef5925@googlegroups.com>
In reply to#29557
4ndre4 wrote:
> wrote:

> [...]
>> I disagree.  I would suggest that C++/Java/C# are among the *worst*
>> ways to learn OOP.
 
> I wouldn't suggest C++ either because, with the latest additions of 
> C++11 and C++14 (and the C++17 to come), the language has become much 
> more complex and can be confusing for a newsbie. 

That is part of my reason, and certainly why I would be more adamantly
opposed to C++ over C# or Java.


> Java and C# are good 
> choices to learn OOP though. The classic three tenets of OOP, 
> encapsulation, inheritance and polimorphism, are implemented by both 
> languages.

Even these three tenets layer on more than is really necessary for
proper understanding of OOP.  OOP is all about objects passing messages
to one another.  Yes, you will have to know something about polymorphism
and encapsulation to this properly, and most likely about inheritance
too, but starting with objects communicating through messages is the
critical point.

The additional boilerplate of C# or Java on top of that simple notion
make them, to my mind, less than ideal for learning the principles of
OOP.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#29565

From4ndre4 <4ndre4@4ndre4.com.invalid>
Date2016-02-06 18:48 +0000
Message-ID<n95f0j$hcv$3@dont-email.me>
In reply to#29563
On 06/02/2016 16:24, Scott Sauyet wrote:

[...]
> Even these three tenets layer on more than is really necessary for
> proper understanding of OOP.

Given that those tenets constitute OOP, it is hardly so.

>OOP is all about objects passing messages
> to one another.

OOP is not just that. OOP is about encapsulation, inheritance and 
polymorphism. Polymorphism is the most important concept to master, in 
order to build a meaninful object hierarchy.

> The additional boilerplate of C# or Java on top of that simple notion

Which boilerplate? You can build a simple interface in C#/Java, 
implement it, inherit from a class, have a polymorphic behaviour at a 
snap of the fingers. Where is the boilerplate?

-- 
4ndre4
"The use of COBOL cripples the mind; its teaching should, therefore, be 
regarded as a criminal offense." (E. Dijkstra)
"Ora, questo "Delta11" non è nulla di più di uno scemo del villaggio" - 
http://goo.gl/1nrkkX

[toc] | [prev] | [next] | [standalone]


#29566

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-02-06 12:28 -0800
Message-ID<655ac788-5a00-447c-a148-08287f3c87bd@googlegroups.com>
In reply to#29565
4ndre4 wrote:
> Scott Sauyet wrote:
> 
> [...]
>> Even these three tenets layer on more than is really necessary for
>> proper understanding of OOP.
> 
> Given that those tenets constitute OOP, it is hardly so.

Of course we can debate the terms all we want; we may never be able
to convince one another, and I won't go another round of this, as
I think we're fairly far afield from what comp.lang.javascript
usually covers, but I will try one more time to articulate why I 
think this is wrong.  Feel free to have the last word.

In a response to (our own?) Stefan Ram, Alan Kay, who coined the
term "object-oriented", said, "OOP to me means only messaging, local 
retention and protection and hiding of state-process, and extreme 
late-binding of all things."

The entire exchange [1] is well worth a read.  Dr. Kay also partially
disavows at least the word "polymorphism" as not flexible enough to
capture what he was looking for, and more firmly disavows existing
(circa 2003) strong type systems.

While I don't believe that Dr. Kay has the right to dictate the ongoing
discussion of the term, he is also in a quite privileged place with
respect to it.  These ideas are worth serious consideration.  And to
me, they are quite convincing.

It is for these reasons that I find the class-based, high-ceremony OOP
languages to be substantially less persuasive than ones which manage
other simpler forms of OOP.  


>> OOP is all about objects passing messages to one another.
> 
> OOP is not just that. OOP is about encapsulation, inheritance and 
> polymorphism. Polymorphism is the most important concept to master, in 
> order to build a meaninful object hierarchy.

I believe those ideas have been layered onto a simpler core.  That core
is to me what OOP is all about.


>> The additional boilerplate of C# or Java on top of that simple notion
> 
> Which boilerplate? You can build a simple interface in C#/Java, 
> implement it, inherit from a class, have a polymorphic behaviour at a 
> snap of the fingers. Where is the boilerplate?

The entire class syntax seems overhead to me.  I might to do this in
Javascript:

    const baseRect = {
      area: function() {return this.width * this.height},
      perimeter: function() {return 2 * this.width + 2 * this.height}
    };

    const r1 = Object.create(baseRect);
    r1.height = 5; 
    r1.width = 8;

    r1.area(); //=> 40

But in Java, the norm would be something more like this:

    public class Rectagle {

      private double width;
      private double height;

      public double area() {
        return width * height;
      }

      public double circumference() {
        return 2 * width + 2 * height;
      }
    
      public void setHeight(height) {
        this.height = height;
      }
    
      public void getHeight() {
        return this.height;
      }
    
      public void setWidth(width) {
        this.width = width;
      }
    
      public void getWidth() {
        return this.width;
      }
    }

    public Rectangle r1 = new Rectangle();
    r1.setHeight(5);
    r1.setWidth(8);

    r1.area(); //=> 40

All that extra code seems overhead to me.  And I think that people who
learn OOP only through code like this miss most of what's really
important about it.


  [1]: <http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en>

  -- Scott

[toc] | [prev] | [next] | [standalone]


#29568

From4ndre4 <4ndre4@4ndre4.com.invalid>
Date2016-02-06 21:01 +0000
Message-ID<n95mp3$hcv$6@dont-email.me>
In reply to#29566
On 06/02/2016 20:28, Scott Sauyet wrote:

[...]
> In a response to (our own?) Stefan Ram, Alan Kay, who coined the
> term "object-oriented", said, "OOP to me means only messaging, local
> retention and protection and hiding of state-process, and extreme
> late-binding of all things."

"Where polymorphic calls--or any other binding operation--aren't 
resolved until runtime." - http://www.c2.com/cgi/wiki?LateBinding

Alan Kay is mentioning just polymorphism when he says "late-binding of 
all things", and that's the way it works in languages such as C++, Java, 
and C#.

> It is for these reasons that I find the class-based, high-ceremony OOP
> languages to be substantially less persuasive than ones which manage
> other simpler forms of OOP.

Non sequitur. Like it or not, if someone wants to learn about OOP today, 
they cannot ignore the way OOP is implemented by the major languages 
around. You aren't really suggesting that the OP just sticks to 
JavaScript, are you?

> I believe those ideas have been layered onto a simpler core.  That core
> is to me what OOP is all about.

Again, no it's not. You cannot ignore how object-oriented programming is 
implemented by the major object-oriented languages, today.

> The entire class syntax seems overhead to me[...]

What the hell does *syntax* have to do with that? You will always find a 
language that is more concise than others (Python or Haskell, for 
example). The important thing is how *concepts* are implemented by a 
language, not the syntax used to express them. Java and JavaScript have 
*different* object models, one is class-based, the other 
prototype-based. You may like one more than the other, but you cannot 
certainly say that Java is not good to learn OOP. Java is more tied to 
the classic idea of OOP, where encapsulation, inheritance and 
polymorphism are available *in a very simple way*.

-- 
4ndre4
"The use of COBOL cripples the mind; its teaching should, therefore, be 
regarded as a criminal offense." (E. Dijkstra)
"Ora, questo "Delta11" non è nulla di più di uno scemo del villaggio" - 
http://goo.gl/1nrkkX

[toc] | [prev] | [next] | [standalone]


#29577

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-02-07 15:23 -0800
Message-ID<bc76b2fa-4b42-4a21-86c4-f70e51aae878@googlegroups.com>
In reply to#29568
4ndre4 wrote:
> Scott Sauyet wrote:

>> The entire class syntax seems overhead to me[...]
> 
> What the hell does *syntax* have to do with that?

Thank you for the correction.  It's certainly not just syntax that I
object to; it's actually the notion of classes as defined by popular
OOP languages that obscures the real benefits of OOP.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#29578

FromAleksandro <aleksandro@gmx.com>
Date2016-02-08 11:45 -0300
Message-ID<n9a9ge$qbp$1@dont-email.me>
In reply to#29577
On 07/02/16 20:23, Scott Sauyet wrote:
> 4ndre4 wrote:
>> Scott Sauyet wrote:
> 
>>> The entire class syntax seems overhead to me[...]
>>
>> What the hell does *syntax* have to do with that?
> 
> Thank you for the correction.  It's certainly not just syntax that I
> object to; it's actually the notion of classes as defined by popular
> OOP languages that obscures the real benefits of OOP.

What are exactly these real benefits? how are these benefits
specifically obscured and what would you suggest?

[toc] | [prev] | [next] | [standalone]


#29582

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2016-02-08 13:39 -0800
Message-ID<f055f38f-6946-442f-a63e-f5da35056fee@googlegroups.com>
In reply to#29565
On Saturday, February 6, 2016 at 12:48:43 PM UTC-6, 4ndre4 wrote:
> On 06/02/2016 16:24, Scott Sauyet wrote:

> >OOP is all about objects passing messages
> > to one another.
> 
> OOP is not just that. OOP is about encapsulation, inheritance and 
> polymorphism. Polymorphism is the most important concept to master, in 
> order to build a meaninful object hierarchy.

The generally accepted definition of OOP is described by Benjamin Pierce in TAPL [1][2]. Namely:

1. Multiple representations
2. Encapsulation
3. Subtyping
4. Inheritance
5. Open recursion

[1] <https://www.cis.upenn.edu/~bcpierce/tapl/>
[2] See Chapter 18.1 <http://port70.net/~nsz/articles/book/pierce_types_and_programming_languages_2002.pdf>

[toc] | [prev] | [next] | [standalone]


#29589

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-02-11 08:09 -0800
Message-ID<811777f5-0dcc-4525-900f-e20a98cbc55b@googlegroups.com>
In reply to#29582
Michael Haufe (TNO) wrote:
> 4ndre4 wrote:
>> Scott Sauyet wrote:
> 
>>> OOP is all about objects passing messages to one another.
>> 
>> OOP is not just that. OOP is about encapsulation, inheritance and 
>> polymorphism. Polymorphism is the most important concept to master, in 
>> order to build a meaninful object hierarchy.
> 
> The generally accepted definition of OOP is described by Benjamin 
> Pierce in TAPL [1][2]. Namely:
> 
> 1. Multiple representations
> 2. Encapsulation
> 3. Subtyping
> 4. Inheritance
> 5. Open recursion
> 
> [1] <https://www.cis.upenn.edu/~bcpierce/tapl/>
> [2] See Chapter 18.1 <http://port70.net/~nsz/articles/book/pierce_types_and_programming_languages_2002.pdf>

With some caveats about what precisely is meant by inheritance, this 
is at least not inconsistent with the quotation from Alan Kay given
earlier, and much of it is implied by what he says there.

What is not implied at all in either, though, is the notion of classes,
especially as defined in the C++ family, as the primary mechanism to
create objects.  (Although Pierce's book certainly does note that this
is a common technique.)

  -- Scott

[toc] | [prev] | [next] | [standalone]


#29590

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2016-02-11 12:22 -0800
Message-ID<76b604b4-565c-4125-ab78-5b1ef68b5b56@googlegroups.com>
In reply to#29589
On Thursday, February 11, 2016 at 10:09:42 AM UTC-6, Scott Sauyet wrote:
> Michael Haufe (TNO) wrote:
> > 4ndre4 wrote:
> >> Scott Sauyet wrote:
> > 
> >>> OOP is all about objects passing messages to one another.
> >> 
> >> OOP is not just that. OOP is about encapsulation, inheritance and 
> >> polymorphism. Polymorphism is the most important concept to master, in 
> >> order to build a meaninful object hierarchy.
> > 
> > The generally accepted definition of OOP is described by Benjamin 
> > Pierce in TAPL [1][2]. Namely:
> > 
> > 1. Multiple representations
> > 2. Encapsulation
> > 3. Subtyping
> > 4. Inheritance
> > 5. Open recursion
> > 
> > [1] <https://www.cis.upenn.edu/~bcpierce/tapl/>
> > [2] See Chapter 18.1 <http://port70.net/~nsz/articles/book/pierce_types_and_programming_languages_2002.pdf>
> 
> With some caveats about what precisely is meant by inheritance, this 
> is at least not inconsistent with the quotation from Alan Kay given
> earlier, and much of it is implied by what he says there.
> 
> What is not implied at all in either, though, is the notion of classes,
> especially as defined in the C++ family, as the primary mechanism to
> create objects.  (Although Pierce's book certainly does note that this
> is a common technique.)

Have you seen the Treaty of Orlando? [1]

[1] <http://web.media.mit.edu/~lieber/Publications/Treaty-of-Orlando-Treaty-Text.pdf>

[toc] | [prev] | [next] | [standalone]


#29593

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-02-12 11:09 +0000
Message-ID<3afrbbhcujk6pjslkg1h5nj2gj4768eqpc@4ax.com>
In reply to#29590
On Thu, 11 Feb 2016 12:22:35 -0800 (PST), "Michael Haufe (TNO)"
<tno@thenewobjective.com> wrote:

>On Thursday, February 11, 2016 at 10:09:42 AM UTC-6, Scott Sauyet wrote:
>> Michael Haufe (TNO) wrote:
>> > 4ndre4 wrote:
>> >> Scott Sauyet wrote:
>> > 
>> >>> OOP is all about objects passing messages to one another.
>> >> 
>> >> OOP is not just that. OOP is about encapsulation, inheritance and 
>> >> polymorphism. Polymorphism is the most important concept to master, in 
>> >> order to build a meaninful object hierarchy.
>> > 
>> > The generally accepted definition of OOP is described by Benjamin 
>> > Pierce in TAPL [1][2]. Namely:
>> > 
>> > 1. Multiple representations
>> > 2. Encapsulation
>> > 3. Subtyping
>> > 4. Inheritance
>> > 5. Open recursion
>> > 
>> > [1] <https://www.cis.upenn.edu/~bcpierce/tapl/>
>> > [2] See Chapter 18.1 <http://port70.net/~nsz/articles/book/pierce_types_and_programming_languages_2002.pdf>
>> 
>> With some caveats about what precisely is meant by inheritance, this 
>> is at least not inconsistent with the quotation from Alan Kay given
>> earlier, and much of it is implied by what he says there.
>> 
>> What is not implied at all in either, though, is the notion of classes,
>> especially as defined in the C++ family, as the primary mechanism to
>> create objects.  (Although Pierce's book certainly does note that this
>> is a common technique.)
>
>Have you seen the Treaty of Orlando? [1]
>
>[1] <http://web.media.mit.edu/~lieber/Publications/Treaty-of-Orlando-Treaty-Text.pdf>

To say it another way, the purpose of OO design and OO languages is to
help us make things that work. There are several approaches to this.
Which you prefer depends on circumstances and personal choice. It's
not something to argue about too fiercely.

Myself, I prefer C++. For instance, you can make complex numbers,
which are unknown to the compiler, look like ordinary numbers, as in 
  complex x, y, z;  ...  z = 2*x + 3/y;
I don't think many other languages are this fluent. Oh, and it's not
necessary to start by deciding that complex number is_a number is_a
maths concept.

  John

PS It's not so much the C++ family, it's more the Simula family.

[toc] | [prev] | [next] | [standalone]


#29594

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2016-02-12 13:34 -0800
Message-ID<e6fae746-a30c-4c23-ab93-e3a2b3e8b589@googlegroups.com>
In reply to#29593
On Friday, February 12, 2016 at 5:09:55 AM UTC-6, John Harris wrote:

> To say it another way, the purpose of OO design and OO languages is to
> help us make things that work. There are several approaches to this.
> Which you prefer depends on circumstances and personal choice. It's
> not something to argue about too fiercely.

"To each their own" and "just another tool in the toolbox" are simply cop-outs. PLT matters. It matters significantly as lives + billions of dollars are lost due to bad language design, that includes the subtle differences in so-called "OOP" languages. Would you feel comfortable flying in a plane where the software was written in a mixture of assembly and (god-forbid) Coffee-script? I suspect not, and that you would much rather have another language with OO support such as Ada.


> Myself, I prefer C++. For instance, you can make complex numbers,
> which are unknown to the compiler, look like ordinary numbers, as in 
>   complex x, y, z;  ...  z = 2*x + 3/y;
> I don't think many other languages are this fluent. Oh, and it's not
> necessary to start by deciding that complex number is_a number is_a
> maths concept.

This is a trivial extension in the Lisp family of languages. Yet even ignoring the syntactic aspect of it, you can add the semantics of complex numbers to JavaScript as well by treating the components as well... components of an object:

var myNumber = new Complex(a,b)


> PS It's not so much the C++ family, it's more the Simula family.

[toc] | [prev] | [next] | [standalone]


#29595

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-02-13 14:40 +0000
Message-ID<hufubblbp6h65meriph2c6o1u0a88n23co@4ax.com>
In reply to#29594
On Fri, 12 Feb 2016 13:34:06 -0800 (PST), "Michael Haufe (TNO)"
<tno@thenewobjective.com> wrote:

>On Friday, February 12, 2016 at 5:09:55 AM UTC-6, John Harris wrote:
>
>> To say it another way, the purpose of OO design and OO languages is to
>> help us make things that work. There are several approaches to this.
>> Which you prefer depends on circumstances and personal choice. It's
>> not something to argue about too fiercely.
>
>"To each their own" and "just another tool in the toolbox" are simply cop-outs. 

Make things that *work* includes choosing a suitable language as well
as the OO style. I'm not advocating the use of Basic or equivalent for
banking systems.


>PLT matters. 

Photonic Laser Thruster ? (See Wikipedia)


>It matters significantly as lives + billions of dollars are lost due to bad language design, that includes the subtle differences in so-called "OOP" languages. Would you feel comfortable flying in a plane where the software was written in a mixture of assembly and (god-forbid) Coffee-script? I suspect not, and that you would much rather have another language with OO support such as Ada.

Some software guru whose name I've forgotten said that he would never
fly in a plane that used Fortran for its control software.

And NASA lost a mission to Venus because Fortran isn't upset by
certain simple and difficult to spot typing errors.

So, yes, some languages aren't the best choice, so not Fortran. Unless
you can't do the work without a Maths package that's in Fortran.


>> Myself, I prefer C++. For instance, you can make complex numbers,
>> which are unknown to the compiler, look like ordinary numbers, as in 
>>   complex x, y, z;  ...  z = 2*x + 3/y;
>> I don't think many other languages are this fluent. Oh, and it's not
>> necessary to start by deciding that complex number is_a number is_a
>> maths concept.
>
>This is a trivial extension in the Lisp family of languages. Yet even ignoring the syntactic aspect of it, you can add the semantics of complex numbers to JavaScript as well by treating the components as well... components of an object:
>
>var myNumber = new Complex(a,b)
  <snip>

I'm pointing out that C++ will let you write
  Complex a,b,c;     ...  a = b + c;
  Polynomial d,e,f;  ...  d = e + f;
  Quaternion g,h,i;  ...  g = h + i;
not 
  a = addComplex(b, c);
  d = addPoly(d, f);
  g = addQuaternion(h, i);
It's easier to write, and easier to proof-read, which is what matters.

  John

[toc] | [prev] | [next] | [standalone]


#29599

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2016-02-14 10:18 -0800
Message-ID<d2ed95f3-8320-42cb-baf2-50a9f7e80ee2@googlegroups.com>
In reply to#29595
On Saturday, February 13, 2016 at 8:40:30 AM UTC-6, John Harris wrote:

> Make things that *work* includes choosing a suitable language [...]

Indeed. Optimally one should program against the Problem Domain in a language that suits it otherwise you're programming against some other Problem Domain which as a side effect, you hope, solves the original problem you were worried about. [1]

> as well as the OO style.

I'm not sure there are "style[s]" of OO.

> I'm not advocating the use of Basic or equivalent for
> banking systems.

I wasn't suggesting you were. Though given that COBOL is the legacy implementation of most financial institutions in the USA at least, I don't think it would necessarily be a step backwards if it was. A bit of structured programming would be nice. "If it ain't broke don't fix it" is the name of the game there though. My main point on this though is to remind people that some languages are better than others. 

Michael Haufe (TNO) wrote:
> > [...]
> >PLT matters. 

> Photonic Laser Thruster ? (See Wikipedia)

Given the context of the conversation, there were four possibilities I think you could have chosen from in the Wikipedia disambiguation page, excluding the one you chose. I was referring to Programming Language Theory [2]

> Some software guru whose name I've forgotten said that he would never
> fly in a plane that used Fortran for its control software.
> 
> And NASA lost a mission to Venus because Fortran isn't upset by
> certain simple and difficult to spot typing errors.
> 
> So, yes, some languages aren't the best choice, so not Fortran. Unless
> you can't do the work without a Maths package that's in Fortran.

A valid concern. Numerous versions of FORTRAN let you redefine the meaning of numbers, among many other flaws. [3] Defensive programming is a must-have to successfully develop at scale in this language, otherwise you have to have a very in depth code review stage in your development lifecyle + unit/integration tests. 

Luckily for your Software Guru acquaintance, Ada is used instead in many cases [4]

> 
> I'm pointing out that C++ will let you write
>   Complex a,b,c;     ...  a = b + c;
>   Polynomial d,e,f;  ...  d = e + f;
>   Quaternion g,h,i;  ...  g = h + i;
> not 
>   a = addComplex(b, c);
>   d = addPoly(d, f);
>   g = addQuaternion(h, i);
> It's easier to write, and easier to proof-read, which is what matters.

If it's simply a preference of notation, fine; but semantically equivalent. It has been said that syntax is the last refuge of linguistic Luddites, and some part of me agrees. I suspect this is a priority to you because among the variety of languages you've learned/used, the only main difference between them has been a choice of syntax and library offerings. In comparison to other aspects of what goes into the design of a programming language though, this aspect (while important in its own right), is quite low on the totem pole. Admittedly, some people know how to utterly screw up even the simplest things [5]


[1] Alan Perlis Epigram #8 
    "A programming language is low level when its programs require attention to the irrelevant."
    <http://www.cs.yale.edu/homes/perlis-alan/quotes.html> 
[2] <https://en.wikipedia.org/wiki/Programming_language_theory>
[3] <http://everything2.com/title/Changing+the+value+of+5+in+FORTRAN>
[4] <http://archive.adaic.com/projects/atwork/boeing.html>
[5] <http://homepages.inf.ed.ac.uk/wadler/language.pdf>

[toc] | [prev] | [next] | [standalone]


#29602

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-02-14 21:27 +0100
Message-ID<2037515.a2iippbiA5@PointedEars.de>
In reply to#29599
Stefan Ram wrote:

> "Michael Haufe (TNO)" <tno@thenewobjective.com> writes:
>>On Saturday, February 13, 2016 at 8:40:30 AM UTC-6, John Harris wrote:
>>>I'm pointing out that C++ will let you write
>>>Complex a,b,c;     ...  a = b + c;
> 
> error: expected primary-expression before '...' token
>    Complex a,b,c;     ...  a = b + c;
>                       ^

<https://en.wikipedia.org/wiki/Ellipsis>
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web