Async Class

Isiah Meadows isiahmeadows at gmail.com
Mon Feb 19 18:32:37 UTC 2018


I just thought I'd politely point out here that JS isn't a purely OO
language (it's even less so class-based OO - ES classes are about 90%
sugar over prototype-based inheritance\*). Also, C#, the language that
*first* had this kind of syntax, [also doesn't have this][1].
Constructors should be seen as *what allocates and instantiates the
instance*, not *what loads and creates the instance*, and nearly every
OO language out there assumes the former model, that of
allocation/instantiation. (C++ is one of the unusual ones that
conflates the two with its RAII.)

\* There's a few features ES classes offer that prototypes don't, with
`new.target` being the biggest one. But in general, ES classes aren't
like traditional classes - they can be easily modified, up to and
including their inheritance chain (which is downright trivial). Also,
duck typing is reified in the spec, with that being used instead of
interfaces when subclassing. Contrast this with Python, which makes it
very difficult to change inheritance chains at runtime, and Ruby,
[which has had bugs over invalid assumptions with this][2] (Classes
don't invalidate their method caches with `initialize_copy`).

[1]: https://stackoverflow.com/questions/8145479/can-constructors-be-async
[2]: https://github.com/charliesome/charlie.bz/blob/master/posts/changing-the-superclass-of-a-class-in-ruby.md
-----

Isiah Meadows
me at isiahmeadows.com

Looking for web consulting? Or a new website?
Send me an email and we can get started.
www.isiahmeadows.com


On Mon, Feb 19, 2018 at 12:41 PM, Dimitrian Nine
<dimtimeforever at gmail.com> wrote:
> "why a static factory"
>
> I answered earlier:
> <<Maybe, but i think it question similiar to "factory vs class">>
>
> Yes, you can, but for me more easy to work with classes.
> And i just want to extend the functionality for work with async - that all.
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the es-discuss mailing list