Re: Summary: prototypes as classes

2011-07-11 Thread Bob Nystrom
I agree with Brendan's replies, but just to add some more color: On Sat, Jul 2, 2011 at 11:46 AM, Angus Croll anguscr...@gmail.com wrote: The concept itself is very simple - a dynamic archetype to be shared by all my instances: my prototype changes, my instances know about it. I would not

Re: Summary: prototypes as classes

2011-07-11 Thread Dmitry A. Soshnikov
On 12.07.2011 0:18, Bob Nystrom wrote: I agree with Brendan's replies, but just to add some more color: On Sat, Jul 2, 2011 at 11:46 AM, Angus Croll anguscr...@gmail.com mailto:anguscr...@gmail.com wrote: The concept itself is very simple - a dynamic archetype to be shared by all my

Re: Summary: prototypes as classes

2011-07-11 Thread Axel Rauschmayer
I am warming up to class literals: they should help IDEs and will make future extensions easier (mixins etc.). Note that they are not mutually exclusive with prototypes as classes. On Jul 11, 2011, at 22:18 , Bob Nystrom wrote: I agree with Brendan's replies, but just to add some more color:

Re: Summary: prototypes as classes

2011-07-02 Thread Angus Croll
I think its important to make a distinction between chained and unchained prototypes... By unchained prototypes I mean those that directly extend Object.prototype (note that that every built-in prototype specified by ES5 is unchained). Unchained prototypes are gorgeous - one instance defining

Re: Summary: prototypes as classes

2011-07-02 Thread Brendan Eich
On Jul 2, 2011, at 2:04 PM, Brendan Eich wrote: Remember, I'm the one who is a little sad about classes making the ES.next cutoff. Also I agree with dherman that they have too many option open, of course issues and would benefit from reductions (minimal classes, see ).

Re: Summary: prototypes as classes

2011-07-02 Thread Brendan Eich
On Jul 2, 2011, at 4:10 PM, Angus Croll wrote: I'd argue its a difference in meaning - the proof is that if you removed 'extends' and 'super', the class sugar would support unchained prototypes only. In fact maybe I could live with 'class' alone (though it might give noobs the wrong idea

Re: Summary: prototypes as classes

2011-06-30 Thread Thaddee Tyl
From: Axel Rauschmayer a...@rauschma.de On the other hand people may find Point.new(x, y) as intuitive, as they will think of ruby instead of java. As an aside, you can see API code for the above functionality here: - https://github.com/Gozala/selfish [Irakli, updated] -

Re: Summary: prototypes as classes

2011-06-29 Thread Axel Rauschmayer
That is complexity that is added to make things compatible with constructor functions and current built-ins. If you have to factor that in, then it is indeed hard to argue in favor of prototypes-as-classes. There has to be a constructor function somewhere, somehow. The issue is what name

Re: Summary: prototypes as classes

2011-06-29 Thread Brendan Eich
On Jun 29, 2011, at 1:48 PM, Axel Rauschmayer wrote: Prototypes-as-classes (starting from scratch, with a clean protocol that has no notion of constructor functions): new C(x,y) desugars (conceptually!) to (new C).constructor(x,y) With: (1) Instantiation: new C (2)

Re: Summary: prototypes as classes

2011-06-29 Thread Axel Rauschmayer
That's all neat in a kind of desugaring ftw, nerdcore way, but tl;dr -- users don't care and they want to write new C and have it just work (mostly; granted some crack the code, for a few good and bad purposes). Note that I am arguing from the perspective of a language that only has PaCs,

Re: Summary: prototypes as classes

2011-06-29 Thread Brendan Eich
On Jun 29, 2011, at 2:24 PM, Axel Rauschmayer wrote: That's all neat in a kind of desugaring ftw, nerdcore way, but tl;dr -- users don't care and they want to write new C and have it just work (mostly; granted some crack the code, for a few good and bad purposes). Note that I am arguing

Re: Summary: prototypes as classes

2011-06-29 Thread Axel Rauschmayer
Last concrete disagreement we had was over new C() vs. C() in the current language being notably different from new C() vs. C.constructor() in the alternate-reality language with prototypes as classes. As in “don’t mix too well”. I agree with that. That will be a challenge for class

Re: Summary: prototypes as classes

2011-06-29 Thread Irakli Gozalishvili
There have been multiple thread on this and I did not know were to comment, so I'll add few comments here. I think that whole constructors as classes business in JS is confusing for everyone coming to JS, and they only understand it after understanding confusing constructor- prototype

Re: Summary: prototypes as classes

2011-06-29 Thread Axel Rauschmayer
On the other hand people may find Point.new(x, y) as intuitive, as they will think of ruby instead of java. As an aside, you can see API code for the above functionality here: - https://github.com/Gozala/selfish [Irakli, updated] - http://dl.2ality.com/dl/2011/06/Proto.js [me] -- Dr. Axel

Re: Summary: prototypes as classes

2011-06-29 Thread Bill Frantz
On 6/30/11 at 17:46, rfo...@gmail.com (Irakli Gozalishvili) wrote: I think that whole constructors as classes business in JS is confusing for everyone coming to JS, and they only understand it after understanding confusing constructor- prototype relationship. I don't know about others, but I

Re: Summary: prototypes as classes

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 12:34 PM, Bob Nystrom wrote: I like the simplicity of this, but I'm not crazy about how it merges two distinct objects into one. TodayJS (and most class-based languages) let you distinguish two things: 1. A set of properties relevant to the class itself. 2. A set of

Re: Summary: prototypes as classes

2011-06-28 Thread Allen Wirfs-Brock
On Jun 28, 2011, at 8:34 PM, Bob Nystrom wrote: I like the simplicity of this, but I'm not crazy about how it merges two distinct objects into one. TodayJS (and most class-based languages) let you distinguish two things: (actually in the today's most widely used class-based languages

Re: Summary: prototypes as classes

2011-06-28 Thread Mike Shaver
On Tue, Jun 28, 2011 at 3:34 PM, Bob Nystrom rnyst...@google.com wrote: I like the simplicity of this, but I'm not crazy about how it merges two distinct objects into one. TodayJS (and most class-based languages) let you distinguish two things: 1. A set of properties relevant to the class

Re: Summary: prototypes as classes (PaCs)

2011-06-28 Thread Axel Rauschmayer
From: Bob Nystrom rnyst...@google.com Date: June 28, 2011 21:34:30 GMT+02:00 Subject: Re: Summary: prototypes as classes === Class methods becoming instance methods === I agree: This one point is weirder with PaCs than with constructors. It would be great if global variables

Re: Summary: prototypes as classes (PaCs)

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 4:12 PM, Axel Rauschmayer wrote: Explaining constructors-as-classes is really hard, explaining subclassing is even harder. This really depends on the student's background and previous experience. It is not universally true. I bet that in the coming year more new people

Re: Summary: prototypes as classes

2011-06-28 Thread Bob Nystrom
On Tue, Jun 28, 2011 at 3:56 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: (actually in the today's most widely used class-based languages (Java, C#, C++) a class is no an object at all and don't have properties/fields/polymorphic methods/etc. they really are just a scoping mechanism. What

Re: Summary: prototypes as classes

2011-06-28 Thread Axel Rauschmayer
As an aside: - Static methods in Java always felt like a hack, because Java’s creators couldn’t bring themselves to support first-class functions. - Thus: I would much prefer to put Object.* methods into a module (once we have those). The same holds for “class methods” such as Math.*. There Math

Re: Summary: prototypes as classes

2011-06-28 Thread Bob Nystrom
On Tue, Jun 28, 2011 at 5:19 PM, Axel Rauschmayer a...@rauschma.de wrote: As an aside: - Static methods in Java always felt like a hack, because Java’s creators couldn’t bring themselves to support first-class functions. - Thus: I would much prefer to put Object.* methods into a module (once we

Re: Summary: prototypes as classes

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 4:41 PM, Bob Nystrom wrote: From my view, JS-of-today is no less prototype-based than what Axel is proposing, it just wires things up a bit differently. Or is there something I'm missing? Brendan here, you know, the idiot who perpetrated JS. You are not missing

Re: Summary: prototypes as classes (PaCs)

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 5:30 PM, Axel Rauschmayer wrote: What do you do with constructors-as-classes to check the following? o instanceof C You look for C.prototype in the prototype chain of o. No, the JS engine does that! I, or random classy-dynamic-language-experienced users, just do

Re: Summary: prototypes as classes (PaCs)

2011-06-28 Thread Axel Rauschmayer
But with PaCs you don’t have to deconstruct, there is no detour from the class to another construct. I just wrote that with classes or today's constructor functions, no one has to deconstruct, either. Sorry, I meant there is nothing more going on behind the scenes. I remember when I

Re: Summary: prototypes as classes

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 5:45 PM, Axel Rauschmayer wrote: But before you've created an instance, it is pretty handy to have the constructor bound to a name so you can get to it. I don't think making the named object be the constructor means that they're *more* important, just that you generally

Re: Summary: prototypes as classes

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 5:55 PM, Brendan Eich wrote: The prototypes-as-classes approach makes new C(a,b) invoke C.constructor(a, b) with extra rules for object return value, which is a complexity. Sorry, that was unclear: I meant the indirection through .constructor was a complexity, not the

Re: Summary: prototypes as classes

2011-06-28 Thread Axel Rauschmayer
Sorry for dragging this out. The following should be my last email in this thread. The prototypes-as-classes approach makes new C(a,b) invoke C.constructor(a, b) with extra rules for object return value, which is a complexity. Especially for abstractions that want to be callable without

Re: Summary: prototypes as classes

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 6:33 PM, Axel Rauschmayer wrote: Sorry for dragging this out. The following should be my last email in this thread. Axel, thanks for interacting, nothing to apologize for here. The prototypes-as-classes approach makes new C(a,b) invoke C.constructor(a, b) with extra

Re: Summary: prototypes as classes

2011-06-28 Thread Bob Nystrom
On Tue, Jun 28, 2011 at 6:38 PM, Brendan Eich bren...@mozilla.com wrote: It's true, classes want to slide down various lower slopes, over time. The lint brush problem, I called it. We on TC39 are obligated to hold the line. Have you seen this occur in practice? My impression from C++ and C#

Re: Summary: prototypes as classes

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 6:45 PM, Bob Nystrom wrote: On Tue, Jun 28, 2011 at 6:38 PM, Brendan Eich bren...@mozilla.com wrote: It's true, classes want to slide down various lower slopes, over time. The lint brush problem, I called it. We on TC39 are obligated to hold the line. Have you seen this

Re: Summary: prototypes as classes

2011-06-28 Thread Axel Rauschmayer
I’m not arguing in favor of prototypes-as-classes, just against the assertion, below. There has to be a constructor function somewhere, somehow. The issue is what name you invoke it by when calling vs. constructing. With constructor-as-class it's the same name, the name of the abstraction

Re: Summary: prototypes as classes

2011-06-28 Thread Brendan Eich
On Jun 28, 2011, at 8:36 PM, Axel Rauschmayer wrote: I’m not arguing in favor of prototypes-as-classes, just against the assertion, below. I think you missed my point. You can't call a prototype -- it's generally not callable. But in the PaC proposal you can 'new' it. /be