Hacker News new | ask | show | jobs
by Raphmedia 2998 days ago
It doesn't simplifies anything, it simply uses keywords that are familiars to a lot of people.

For someone that has learned JS as his/her first programming language, the new syntax is the one that feels confusing.

1 comments

As someone who learned JS as a first-ish language, I totally love how much simpler and cleaner the syntax is.
Is it really simpler? Let's say you take two equal students with zero knowledge of programming and teach classical to one and prototypical to the other. Would the student learning classical inheritance grok it faster? I doubt it.

I do agree that it is easier to understand the new syntax if you have experience with a language that use the same syntax. However, that's not learning anything new. It's simply using concepts that you already know.

Prototypical inheritance may seem simpler at first glance. But understanding how to use it correctly can be extremely difficult, even for experienced JavaScript developers, mostly because there are so many different ways to achieve almost the same thing, but with subtle differences. For example, you can reuse a single object instance as a prototype for multiple others. Or you can create a new instance of the prototype for each instance of the child. The two are similar, but affect e.g. whether or not properties in the prototype are shared or unique.

In the past I've eventually resorted to copy and paste the same template every time I wanted to use inheritance with prototypes. With classes, I never have to think about these problems anymore. There is one way to define a class, and it always works like I expect it to.

But that's the metric everyone uses to gauge a language.

Look at all the complaining about Lisp and Rust syntax which boils down to "ugh, this is unfamiliar."

But to answer your question, I think they are both within a pebble toss distance of each other. But still much harder than other languages due to `this`. `class` just unifies some patterns people were doing like inheritance.