|
|
|
|
|
by knallfrosch
946 days ago
|
|
> Any kind of function that does not have a fixed input and output gets a lot more complex with static types. If you don't know what kind of data people give your function and you don't know what's supposed to happen, how can you write that function?
I think many people use too strict of a type system. If your function works with any object that has a toString()->string function, then just write an in-line interface that defines it. I actually love TypeScript here. It allows for `any` if you're prototyping, lazy or simply don't care.
It allows mapped types, where the next dev can see how a type came into being - for example, Mutable<T>, Readonly<T>, Required<T>, Partial<T>. The names actually speak for themselves! And it eliminates the Java-style verbosity of creating classes and files all just for a type. |
|
I'd prefer if dynamic languages would converge to gradual typing support, and static languages to gradual dynamic support. TypeScript is an example of the later, and PHP of the former.