3 ms·
Why isn't the question "does adequate testing dramatically reduce the benefits of static typing" asked? Why is static typing privileged by default?
by pfdietz 3y ago
Why isn't the question "does adequate testing dramatically reduce the benefits of static typing" asked? Why is static typing privileged by default?
- tshaddox 3y agoProbably because using a static type system gives you those benefits "for free," whereas unit tests are things you need to write and maintain. ("For free" in scare quotes because of course there are always tradeoffs between different programming languages.)
- pfdietz 3y agoThe counterargument is that for sufficiently reliable software extensive testing is needed anyway, and if you do that you find the type errors "for free". If the testing is insufficient, as in practice it often surely is, then static typing would seem to be more valuable.
- peterfirefly 3y agoIt is asked. A lot.
- mayoff 3y agoI wouldn’t say static typing is privileged, but that testing is disadvantaged, because, in the words of Edsger Dijkstra, “Program testing can be used to show the presence of bugs, but never to show their absence!” https://www.cs.utexas.edu/users/EWD/transcriptions/EWD02xx/EWD249/EWD249.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD02xx/E...
- funcDropShadow 3y agoWe could paraphrase Dijkstra --- with some liberty -- to say, "Formal verification of programs can only show the specification is fulfilled, not that the specification is adequate."
- throwaway2037 3y ago"[A]dequate testing": Woah, I love this term. It is judgmental right from the start. It's right up there with "convention over configuration" and "well, if you wear your face mask _correctly_..." I once saw a blog post from an embedded programmer talking about how difficult it is to write "adequate" unit tests for embedded code. If you are writing code that will run in a heart pace maker or aeroplane auto-pilot/lander, it needs to be insanely well tested.
- pfdietz 3y agoIt's not judgmental in some dubious way. "Adequate" here means adequate to ensure the software achieves a specified (and high) level of reliability. If testing is enough to ensure the software is reliable, does the extra benefit of static typing make it worth the cost? This could be quite a lot of testing! The more testing that is done, the fewer type bugs remain that static typing would have found. The argument you want to make against this is that static typing would have benefit beyond just finding bugs. The argument you don't want to make is that static typing reduces the need for testing.
- pjc50 3y agoIt's not "privileged", it's better.
- funcDropShadow 3y agoA bold claim, which is obviously false. To see that compare Clojure's dynamic type system with C's static type system. So perhaps a more nuanced stance is needed.