News for hackers. Stuff that matters.
Re:Ask HN: Resources for catching up on modern JavaScript fo... by chrismeller on Tuesday April 10, 2018 @12:54PM (#16802870)
Why would you ever recommend against using actual ES6 classes? Not only is it the new standard, he’s coming from Java...

TBH, the only reason that seems to make sense is some kind of weird “I knew JavaScript before it had classes!” kind of sentiment that wouldn’t actually teach him anything of value.

Re:Ask HN: Resources for catching up on modern JavaScript fo... by chatmasta on Tuesday April 10, 2018 @01:15PM (#16803059)
I use ES6 classes every day, and I would recommend it. However, for someone coming from a language like Python, it's easy to get confused over inheritance issues where JS does not behave like Python (or Java for that matter).

It doesn't need to be extreme. I just recommended writing one or two "classes" using the old style, in the beginning, because that's a great way to solidify understanding of how the inheritance actually works. Whereas when you're using ES6 classes, you're using hidden abstractions that can make debugging very confusing if you don't know what the "class" keyword is doing.

Re:Ask HN: Resources for catching up on modern JavaScript fo... by MoTTs_ on Thursday April 12, 2018 @02:52AM (#16818578)
On the contrary, classes and inheritance in both Python and JavaScript behave basically the same. In Python, classes are objects (a building, not a blueprint), and inheritance is done by delegation.

https://i.imgur.com/p9Kw815.png

If you've used Python classes and inheritance all this time and never felt confused, then people can also use JavaScript's classes and inheritance and never feel confused.

Re:Ask HN: Resources for catching up on modern JavaScript fo... by chrismeller on Tuesday April 10, 2018 @03:02PM (#16804104)
I came from a C# background, not Java, but didn’t find anything supremely confusing about class inheritance in JS. Differences to be sure, but nothing that was groundbreaking.

Debugging I can see as being a reasonable argument - as you step through code you should understand what “proto” means. That’s the most compelling reason I’ve seen thus far...

Re:Ask HN: Resources for catching up on modern JavaScript fo... by thinkxl on Tuesday April 10, 2018 @01:05PM (#16802952)
Prototypal inheritance plays a huge role in understanding the language because JavaScript uses it for everything.

It might be a good idea to learn about this before using ES6 classes; remember that ES6 classes are syntactic sugar on top of prototypal inheritance anyway. They wouldn't learn legacy patterns, but the actual pattern that JavaScript uses.

Re:Ask HN: Resources for catching up on modern JavaScript fo... by chrismeller on Tuesday April 10, 2018 @03:11PM (#16804193)
I grant you that it plays (or at least played) a huge part, but as things move towards ES6 classes (which are very similar to every other language with classes), I would still argue that you’re insisting upon learning prototype inheritance for no real reason.
Re:Ask HN: Resources for catching up on modern JavaScript fo... by thinkxl on Tuesday April 10, 2018 @05:50PM (#16805845)
You are missing the point; if you use JavaScript, you use prototypal inheritance whether you like it or not, e.g.:

  function getUser() {} 
That is creating an instance of the `Function` constructor object[1][2]. In a Classical (as classes) language, you would see that like this:

  // `Function` being a class 
  function getUser extends Function {}
but because JavaScript is purely prototypal, this works differently.

You say that there's no reason to learn prototypal inheritance, well, the only and valid reason is that to write at least decent JavaScript you have to understand how it works behind the scenes.

* [1] - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

* [2] - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Edit: add links

Re:Ask HN: Resources for catching up on modern JavaScript fo... by tytytytytytytyt on Tuesday April 10, 2018 @01:16PM (#16803082)
> The "class" keyword is just syntactical sugar on prototypical inheritance so it's a good idea to learn the raw form before the sugared form.

Idk how he could be more clear about why.