4 ms·
> Rubbish, in my experience. People who understand dynamic languages know they need to write tests because it's the only thing asserting correctness. Tests don
by motorest 1y ago
> Rubbish, in my experience. People who understand dynamic languages know they need to write tests because it's the only thing asserting correctness.
Tests don't assert correctness. At best they verify specific invariants.
Statically typed languages lean on the compiler to automatically verify some classes of invariants (i.e., can I call this method in this object?)
With dynamically typed languages, you cannot lean on the compiler to verify these invariants. Developers must fill in this void by writing their own tests.
It's true that they "need" to do it to avoid some classes of runtime errors that are only possible in dynamically typed languages. But that's not the point. The point is that those who complan that statically typed languages are too cumbersome because they require boilerplate code for things type compile-time type checking are also correlated with the set of developers who fail to invest any time adding or maintaining automated test suites, because of the same reasons.
> I could just as easily say static people don't write tests because they think the type system is enough. A type system is laughably bad at asserting correct behaviour.
No, you can't. Developers who use statically typed languages don't even think of type checking as a concern, let alone a quality assurance issue.
- bluGill 1y ago> Tests don't assert correctness. At best they verify specific invariants. Pedantically correct, but in practice those are close enough to the same thing. Even a formal proof cannot assert correctness - requirements are often wrong. However in practice requirements are close enough to correct that we can call a formal proof also close enough.
- globular-toast 1y agoTests assert correctness of behaviour, which is the only thing that really matters. A type system can't do that. Spending time getting your types right just to please the type checker does catch some bugs sometimes, but I'm not convinced it's truly worth it given that bugs usually happen at a much higher level anyway which will lead to rewriting/throwing away the lower level code anyway. It's a completely different tradeoff if those types are also being used to compile the program into native code. No C programmer complains about types because at least we're getting native code with zero overhead. It's a tradeoff that's worth making, sometimes. But there are so many cases where speed does not matter, and there it's much harder to make the case. As always, it's not really about static vs dynamic, strong vs weak, red vs blue, left vs right etc. All have their virtues. The axis that really matters is extremity. Extreme adherence to anything is rarely a good thing.