I have heard discussions about why static typing is superior to testing (and vice versa) as the way to lower the number of bugs in systems, and I t...
For further actions, you may consider blocking this person and/or reporting abuse
Where have people been advocating that you don't need tests if you have a type system? As your article demonstrates very well, a type system only prevents you from having to write tests that ensure the function only works with the correct inputs types and returns the correct type. Or said perhaps said slightly more eloquently:
Tests should be testing for logic errors. The benefit of the type system is that you no longer have to write tests to validate function inputs and outputs. You still need tests for logic.
I have been privy to such discussions on social media involving knowledgeable folks taking extreme positions on both sides.
Yes, as of today, each have their strengths and weaknesses. This may change in the future. Until then, it is best to embrace them both :)
Do you have any links to someone taking an extreme on either side? I'd like to see their arguments.
These were remarks/threads I have seen on Twitter. So, unfortunately, nothing recorded :(
Here's a Twitter thread comparing static typing and testing -- twitter.com/Hillelogram/status/102....
By the way if you read his blog you'll also find interesting stuff on this subject and others (like formal proofs)
I am not saying Hillel or any static typing proponents are wrong. Having worked on program analysis/verification and formal methods, I am saying we need to have a broader and more permissive perspective. Instead of saying "static typing is the end all", it may be better to understand why we operate the way we do and be pragmatic about what it takes to get from where we are to where we want to be.
I definitely agree with the overall thesis, however generic types would help further constrain your equals and less than methods. Both should take the same generic type
T
which would ideally be bounded by someOrdered
orComparable
types.I doubt Python type hints support generics yet.
Anyways, you are right that generics would help. In this sense, richer static typing (e.g., linear types, ownership types, dependent types) might help checking properties/constraints via testing. However, I think we have long ways to go until static typing can tackle the kind of issues tackled by testing.
They do: mypy.readthedocs.io/en/stable/gene...
True dat.
Good to know Python type hints supports generics :)