4 ms·
The type system is like a chain. It's only as strong as its weakest link. A permissive type system which allows for an 'any' type and lets functions specify mul
by jondubois 8y ago
The type system is like a chain. It's only as strong as its weakest link. A permissive type system which allows for an 'any' type and lets functions specify multiple possible return types is about as useful as no type system at all.
At the other extreme, a rigid type system is not good either because it makes it harder to integrate your system/module with third party systems/modules developed by other teams/companies. This is because other teams might be using completely different programming languages and their type system is extremely unlikely to be compatible with yours - This means that if they want to integrate with your code, they need to do a lot of work to convert their own types to match yours and the result just looks ugly; their project ends up with redundant types/interfaces that sound and behave almost the same but are different in ways that are almost impossible to describe let alone understand.
For example, let's say that I import two modules; both of them expose their own `URL` interface. Now both modules chose the same name for interface but one of them exposes a `query` property as a string, but the other one exposes a `query` property as a Map. How do you reconcile these two conflicting types within your system? The result just looks ugly and confusing no matter what you do.