News for hackers. Stuff that matters.
Re:Software correctness is a lot like flossing (2020) by pydry on Friday February 04, 2022 @07:35AM (#30205994)
I tend to find that "wrong type" accounts for a vanishingly small % of production bugs in average python programs.

The only exceptions I experienced this on were on A) projects that had zero tests and B) projects that insisted on passing around dicts and primitives rather than classes.

If the project developed a mimimal level of testing that one might tentatively argue that you'd want anyway to validate behavior and made half an attempt to use OO this class of bug seemed to dry up pretty quickly.

I've also seen Java developers switch to python and write entirely untested code and then get frustrated that they got type errors at runtime that the Java compiler used to catch for them. I wouldnt exactly say I felt sympathetic to their plight.

Re:Software correctness is a lot like flossing (2020) by dllthomas on Friday February 04, 2022 @03:03PM (#30212215)
> "wrong type"

I find that people have very different understandings of what "wrong type" means.

If you restrict yourself to places where python or js actually mention type in the error messages, that misses a whole lot of things that basic use of a simple type system would catch, much less skilled use of a sophisticated type system.

There's an example I give - admittedly tangential given that it does not replace (and could not be replaced by) unit tests, but hopefully giving some insight into the range of what's possible: I once used C's type system to catch "you called this function from the wrong thread" at compile time, converting subtle runtime failures or meaningful runtime overhead into "you can't call this here, dummy" before running anything. This was hugely helpful as requirements evolved and I found myself moving large pieces of functionality between threads.

I don't think this clearly resolves the broader discussion; static type checking is a tool and its applicability may well depend on the problems at hand, the language in question, and the developers involved; I think how it should be applied certainly depends on these things. But I think it is too often dismissed based on an overly narrow understanding of what a "type error" can be.

Re:Software correctness is a lot like flossing (2020) by pydry on Saturday February 05, 2022 @05:31AM (#30219811)
I use asserts in python in a similar manner to the way you used types in C. Combined with tests it's a highly flexible way of "locking down" behaviors that should be impossible.
Re:Software correctness is a lot like flossing (2020) by zppln on Friday February 04, 2022 @08:20AM (#30206428)
This is pretty much my experience as well, including the part about Java programmers.