T.J. Crowder (2017-11-02T08:21:22.000Z)
On Thu, Nov 2, 2017 at 3:43 AM, kai zhu <kaizhu256 at gmail.com> wrote:
> any thoughts? i'll break the ice with a quora question i recently answered

Link to that answer for those who are interested:
https://www.quora.com/Why-is-JavaScript-so-hated/answer/Kai-Zhu-9

> > Why is JavaScript so hated?

I have seen no indication that it is. Quite the reverse. And like Jordan, I
see a lot of love for the improvements in ES2015 and ES2017 (and many of
the current Stage 3 proposals which seem likely to make it to ES2018, like
object rest/spread).

> the primary reason is because traditional oop skills gained from
> c#/c++/java/python/etc translate poorly to javascript.

I disagree. Understanding the concepts of objects and object references,
creation patterns (constructor, builder, etc.), functions/methods,
pass-by-value (which is dominant in those languages), mutability vs.
immutability -- all of these are just the same.

Yes, the fact JavaScript used Java syntax but is prototype-based rather
than class-based can trip people up if they don't have experience of
prototype-based languages (which are less common today than class-based
ones) and don't bother to read a tutorial or two before jumping in.
(Disclosure: I made that mistake, years ago.) There are things to learn in
any new language. I see Java people tripped up by generics or nested
classes every bit as much.

> in javascript, class-instantiated objects are inferior to
> plain-objects, because plain-objects come with
> JSON.stringify/JSON.parse baked-in

No more or less so than objects created with other constructors.

> ..., while classes require
> needless extra serialization/deserialization routines
> which can easily double your codebase or more (as
real-world javascript-code is heavily i/o based).

First, if serialization code is doubling your codebase, you're doing it
wrong. :-)

But more importantly, no, serialization is no easier with objects created
only with the Object constructor than it is with objects created with other
constructors. In both cases, if you want true objects (not just property
bags), you have to reattach their methods. Doing so is not difficult.

> javascript and frontend-programming...

False conflation.

> ...there's currently a civil war going on in frontend-development,

The gentlest characterization I can make of that statement is that
it's...hyperbolic. There is no civil war. There are a couple of different
object creation patterns, and some people use one kind, and other people
use another kind. In both cases, you end up with objects with properties
and methods, which can interoperate just fine. It's like claiming there's a
civil war in the Java world because some projects use constructors and
others use the Builder pattern. E.g., a gross mischaracterization.

-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171102/ef75e1d3/attachment.html>
tj.crowder at farsightsoftware.com (2017-11-02T08:46:24.123Z)
On Thu, Nov 2, 2017 at 3:43 AM, kai zhu <kaizhu256 at gmail.com> wrote:
> any thoughts? i'll break the ice with a quora question i recently answered

Link to that answer for those who are interested:
https://www.quora.com/Why-is-JavaScript-so-hated/answer/Kai-Zhu-9

> > Why is JavaScript so hated?

I have seen no indication that it is. Quite the reverse. And like Jordan, I
see a lot of love for the improvements in ES2015 and ES2017 (and many of
the current Stage 3 proposals which seem likely to make it to ES2018, like
object rest/spread).

> the primary reason is because traditional oop skills gained from
> c#/c++/java/python/etc translate poorly to javascript.

I disagree. Understanding the concepts of objects and object references,
creation patterns (constructor, builder, etc.), functions/methods,
pass-by-value (which is dominant in those languages), mutability vs.
immutability -- all of these are just the same.

Yes, the fact JavaScript used Java syntax but is prototype-based rather
than class-based can trip people up if they don't have experience of
prototype-based languages (which are less common today than class-based
ones) and don't bother to read a tutorial or two before jumping in.
(Disclosure: I made that mistake, years ago.) There are things to learn in
any new language. I see Java people tripped up by generics or nested
classes every bit as much.

> in javascript, class-instantiated objects are inferior to
> plain-objects, because plain-objects come with
> JSON.stringify/JSON.parse baked-in

No more or less so than objects created with other constructors.

> ..., while classes require
> needless extra serialization/deserialization routines
> which can easily double your codebase or more (as
> real-world javascript-code is heavily i/o based).

First, if serialization code is doubling your codebase, you're doing it
wrong. :-)

But more importantly, no, serialization is no easier with objects created
only with the Object constructor than it is with objects created with other
constructors. In both cases, if you want true objects (not just property
bags), you have to reattach their methods. Doing so is not difficult.

> javascript and frontend-programming...

False conflation.

> ...there's currently a civil war going on in frontend-development,

The gentlest characterization I can make of that statement is that
it's...hyperbolic. There is no civil war. There are a couple of different
object creation patterns, and some people use one kind, and other people
use another kind. In both cases, you end up with objects with properties
and methods, which can interoperate just fine. It's like claiming there's a
civil war in the Java world because some projects use constructors and
others use the Builder pattern. E.g., a gross mischaracterization.

-- T.J. Crowder