4 ms·
For example, with static typing one would define many different complex types over the program, in order to have the compiler enforce the many different constra
by victorNicollet 3y ago
For example, with static typing one would define many different complex types over the program, in order to have the compiler enforce the many different constraints (here the value can be null, but not there ; these two values must be provided together ; and so on). Things like structural typing or algebraic data types even allows the creation of unnamed types on the fly. When sum types are used, conditional operators will be used to deconstruct these in a type-safe way, resulting in many branches.
With dynamic typing, one would have only a small number of very different types, because having many types increases the risk of using the wrong one, and having similar types makes it harder to notice that the wrong one is being used. The types must be very simple, because deconstructing complex types requires having branches, and branches should be kept to a minimum because they are hard to cover properly with unit tests.
- evrimoztamur 3y agoThese complex constructs already appear unnamed within dynamically typed programs, you just don't keep track of them at all. The inherent disarray of your unit tests must stem from the complexity of your algorithms, not from your types.