3 ms·
> Is there anyone making that claim? Apart from straw-men? For every intent and purpose, the person I'm replying to is, with an equivalent level of straw-man-n
by Chabsff 3y ago
> Is there anyone making that claim? Apart from straw-men?
For every intent and purpose, the person I'm replying to is, with an equivalent level of straw-man-ness, which is why I phrased it this way.
> So if you claim your type system is going to keep your refactoring safe, I'd say that I'm not the one being delusional.
No, I'm claiming that there are entire categories of bugs that are protected this way, not that it provides universal safety.
> And of course unit tests also tend to, in practice, catch the errors that are caught by types. If you check that a value is equal to 10 rather than 9, you've also implicitly checked that it is not of type PinkElephant.
It provides that if and only if the code invoking the tested function is called with arguments using the same semantics as the ones exercised in the tests, which is impossible to enforce in a dynamic language. I'd even go so far as saying that it is axiomatically impossible for unit testing to be a truly reliable tool in such languages because of the lack of precondition enforcement.
- mpweiher 3y ago> the person I'm replying to is [making that claim] Er, no. I certainly wasn't, and the person you were replying to above that was making the opposite claim: that it's harder than that. And no, the type system doesn't really help all that much, once you have unit tests. Because unlike the unit tests, which checks values (and obviously the types as well, incidentally) the type system only checks the types. So, trivially, if you mix up addition and subtraction, your unit tests will rightfully balk, whereas your type system is going to be "works for me". As I wrote elsewhere in this thread, in my personal experience the type system was happy during a large refactor long before the unit tests were. Which means that there was a lot of stuff that the type system missed. And so if you feel your type system is going to make your refactors safe, well, good luck to you and the poor people who have to use your code.
- Chabsff 3y agoTo address the unit test stuff: I'm not saying that type systems replace unit tests. I'm saying that unit testing in dynamically typed languages is fundamentally deficient. Or in other words: unit tests are made more reliable by type systems. Unit tests can only check outputs for the inputs that are provided during testing. Leaving the input unbounded means that they can only provide guarantees for code that conforms to the tested subset of inputs. I may be able to test that `foo(3) == 4` and foo("foo") == "bar", but since I can't guarantee that `foo({})`, or literally anything else, will never be called, there will always be holes in the safety net they provide. This is something type systems directly address. > And so if you feel your type system is going to make your refactors safe, well, good luck to you and the poor people who have to use your code. safer. It makes them safer, not automatically safe.