by t43562 · 1y ago · 0 comments
It just seems that some people like static types and good for them. Dynamic languages are for those of us who are, perhaps, lazy and want to be free to think about how to solve the problem at a slightly higher level without having to get into details.
For me the details activate my perfectionism and that blocks me from advancing with thinking about the goal and the effort of creating an elegant set of types makes me less willing to suddenly throw everything away when I realise there's a better approach. Dynamic languages give me that ability to "sketch" until I have an answer and at that point I have to ask: do I really need this to be in a higher performance language? Once or twice the answer has been yes but working out the approach in a dynamic language allowed me to do it right in the static language first time.
How many times have you seen a NoneType error or a KeyError? It's probably the most common class of bugs in Python and there's an easy way to eliminate it. And as a nice side effect your code is way easier to understand, navigate and edit.
I still sometimes have to give up and use Any in Python, partly because half the Python community haven't realised their mistake yet. But that's fine. It's still way better.
I thought adding types might help to remove the most trivial mistakes and help me get it into shape faster. All I can say is that it didn't. The easiest mistakes to make were not the kind of things that triggered typing issues.
When I bit the bullet and found some things that could be made testable - only then did the burden start to fall and to sort of exponentially disappear. Each test, crappy and incomplete as it might have been, made it easier to refactor so that the next test could be added. I went from system tests inwards towards unit test because this, again, had the biggest benefit/cost.
So my thesis is that big general tests do more for you at the start and honing in towards more detailed ones returns less and less value. In this model I see types as being fairly detailed level tests so they can happen later on. This is a facetious, throwaway idea that just occurred to me so don't take it too seriously.