| ▲ | locknitpicker 12 hours ago | |
> I show people coming from object oriented backgrounds this page first in order to correct the perception that TypeScript is best used with that programming paradigm. I think you're confusing things. Languages like Java or C# impose an artificial constraint that free functions don't exist and functions can only exist as members of a class. You don't see this constraint in OO languages such as C++. Also, it's a simplistic assertions to claim that classes have no place in TypeScript or aren't idiomatic. That's just nonsense based on specious reasoning. Classes/objects with function members are still the best way to implement some features. I'm seeing too many people writing absurd typescript code who go through great lengths to avoid a class because they think a class is taboo. They pull out convoluted stunts like passing closures as object members, just to avoid the sin of rolling out a class. | ||
| ▲ | tresil 11 hours ago | parent [-] | |
To clarify, I’m not claiming that classes have no place in Typescript. What I’m saying is that many people coming from OOP backgrounds tend to have the mistaken belief that TypeScript is best written with that paradigm. While it can be in some cases, it should not be assumed to be the best way. In fact, the documentation linked above asserts that “free functions over data” are extremely powerful, and “tend to be the preferred model for writing programs in JavaScript.” | ||