Hacker News new | past | comments | ask | show | jobs | submit login

Javascript adopting the class keyword was really bad. What a bizarre language which added something as syntactic sugar in the language but it's a paradigm.



I don't understand this perspective.. people were already using class semantics in JS before the class keyword; but there was so much inconsistency in the patterns they were using to (ab)use Javascript's prototypal inheritance to emulate classes.

The class keyword brings together a 'best practice' set of pre-existing JS features to provide a uniform OOP experience. Yes, classes still work a little bit differently than they do in other languages, but the benefit of being able to expect the same type of class from modern JS libraries doesn't get appreciated enough.

The only drawback I see to its addition is that it abstracts prototypal inheritance and some other key idiosyncrasies of Javascript from newcomers to the language. But the move away from doing things 'the old ways' has worked out much better for Typescript adoption anyway, as it's hard to type things properly when the interface of an object created by a custom 'class' function is just 'whatever the prototype currently has'


Classes are not the problem. Please watch the video linked in the article. It's gold:

https://youtu.be/QM1iUe6IofM?t=93




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: