Hacker News new | ask | show | jobs
by jfengel 1921 days ago
Because Javascript doesn't do much type checking, you lose some of the biggest wins of class-based programming. And as a late addition, it was a bunch of new stuff to learn that didn't appear in legacy libraries. It would have needed a significant win to really boost that. And it just didn't have it.

JS was intended as a scripting language. You didn't spend time crafting your types so that you could do large-scale projects (multiple developers and/or long time spans) that typing really helped. JS's classes didn't do enough to enable that, so JS was never really used for the types of business logic that is most effective for types.

Typescript does add that. But TS pushes towards a function-based development style. Classes add ways of organizing code to that, which is good, and TS makes it more useful. But TS still isn't much adopted to the large-scale projects that really make best use of it. You can use TS non-class Types and do almost as well without having to learn all the new syntax (and more importantly, semantics).

OO is oriented a lot around encapsulating mutable state, but development style really pushes these days around immutable state. It's just easier to debug and scale. (At a performance cost, but if performance is what you're after, you're not writing Javascript.) So function-based code is what you get.