3 ms·
> I assume you mean "needless complexity". It's useful, needed complexity, if your language is strongly typed to start off with. Which JavaScript is not. Of c
by SideburnsOfDoom 14y ago
> I assume you mean "needless complexity".
It's useful, needed complexity, if your language is strongly typed to start off with. Which JavaScript is not.
Of course all complexity comes with cost, and the costs multiply, (a new feature of the type system interacts with all the existing features) even if the complexity is needed it becomes harder to use and understand the more features are added. JavaScript does away with all of that. It has loads of other flaws, but the basic design philosophy is not one that suggests the addition of generics to improve the language.
- asolove 14y agoSo if you don't want any static typing, don't use TypeScript. But if you are adopting TypeScript to retrofit some kind of static typing onto your code, and if you use any kind of functional programming helpers (map, reduce, filter, etc.) then generics are basically a necessity. Otherwise you have two options: define separate methods for mapArrayOfNumbers, mapArrayOfStrings, etc. or have a lot of casts to the ground type and write a lot of code that isn't actually statically typed.