by gruffle · 3y ago · 0 comments
Not really. Lets say you have an `add(a, b)` function. Static typing can guarantee that the function returns a number, but not that it returns the correct number. So you need unit tests anyway.
A unit test `assert_equal(4, add(2, 2))` actually tells you something about the correctness about the function, and it implicitly also verifies that it returns a number. So static typing does not save you anything.
Static typing does have advantages, for example for documentation and for automated refactoring. But it doesn't replace any unit tests.
Static typing is something you use for performance reasons primarily.
If you want to catch errors with static typing you need Haskell or Rust levels of support for it. C# / Java / C++ don't make the grade.
That is not how to decrease the complexity of reasoning about a Python program.
What you should do instead is break the program up into smaller microservices.
Errors that would be caught by static type checking are exceptionally rare when you do commerical development in dynamically typed languages.
You right now are complaining about a problem that only exists with inside your own head.
> Errors that would be caught by static type checking are exceptionally rare when you do commerical development in dynamically typed languages.
Those kinds of errors are not rare at all.