5 ms·
Imagine you need to change the type that's passed to a function. You attempt to update all places, but you miss a path that's in an edge case. Static typing wo
by kllrnohj 6y ago
Imagine you need to change the type that's passed to a function. You attempt to update all places, but you miss a path that's in an edge case.
Static typing would have caught that for you. By waiting until runtime, you've now just potentially shipped a regression.
As a code base gets large, it's just not possible/practical to run all possible ways the code you're editing can be reached. Unless you happen to be lucky enough to have 100% unit test coverage, which very few people do, and running that test suite is somehow quick enough to be a practical alternative to static typing.
- dec0dedab0de 6y agoIf I need to change a type thats passed to a function that already exists and is heavily used, I would either cast the old type to the new type so both work, or create a new function. If I really cared about cleaning it up I would add a deprecation warning when its done the old way.