Echo JS 0.11.0

<~>
stepan6622 558 days ago. link parent 1 point
Hey, many people are not exactly happy how classes are implemented in JS, not just me. Let me know what I don't understand about them :)

Replies

kali 558 days ago. link 1 point
You mention "I don't actually know how to replace classes outside of React." To me, that means you don't really have much experience using classes.

Then "Classes in JavaScript are implemented differently from the others." But classes are implemented in many different ways in various other languages. There is no single "standard" on how classes are or should be implemented. That JS classes are "different" means nothing. Classes in, say, Ruby are quite different than classes in, say, C++. That you should point this out as a problem tells me you don't really have a deep knowledge on classes in general or that you have used them rarely and only in some specific contexts.


"Correctly understanding how this works" is indeed easy. Saying it's not, well...



You allude to class instances "not playing well" with destructuring. I don't know which supposed problems you have (because you offer no explanation on what the problem is), but it anyway feels like a minor, irrelevant thing.


"It's easy to say, "classes are not necessary, just write functions" however, the second you step outside the React ecosystem, it's different." - you say. And this, clearly, says you don't have much experience outside of the React ecosystem. It's not different. "Just write functions" is exactly as easy whether you're using React or not. Nothing at all forces you to use classes when you don't use React. React is not this magical world completely separated from JavaScript... at least not technically; as a cult, well, that's a different subject for a different time.


You say that "classes encourage using inheritance" and that inheritance is an "outdated concept". This is really not so. Inheritance is, again, a tool. If you know how to use it successfully, it is a good tool for you. If you don't and you misuse it, it will be a bad tool for you.



This are your words. It's not me saying you don't understand or that you don't have much experience with them. It's you saying it :)
stepan6622 558 days ago. link -1 point
I have quite a lot experience with classes from Java, C++, and Python. But I will leave your interpretation to you, because it feels like you don't really want to read the article, but rather project your imaginations.