3 ms·
I think one disadvantage of runtime type checking and DbC is that the compiler can't aid you in refactoring. For example, if you add a case to a variant or sum
by neilparikh 9y ago
I think one disadvantage of runtime type checking and DbC is that the compiler can't aid you in refactoring.
For example, if you add a case to a variant or sum type, or change the parameter or return type of some function, in a static type system, the compiler can tell you all the locations you need to change. In a runtime system, you have to find them yourself, or wait till you see an error at runtime.
Now, this is still better than the alternative of having the error propagate until it crashes 10 functions down, but the compiler finding all the places that need to be changed is something I've found to be really useful, especially in early development when there's a lot of refactoring happening. Presumably, this is probably useful in later stages as well, when the system is large enough that you can't expect to find all the uses of a function or type manually.
- spronkey 9y agoIDEs can still substantially aid in refactoring with runtime type checking and return type annotations - see WebStorm and PHPStorm for two good examples of this. It isn't perfect - but certainly for things like changing the return type of functions, it will usually get you at least 90% of the way there. Now, whether you consider that's actually helping solve the refactoring, or actually introducing new bugs, well - that's another issue :)