Removing a field in a data structure is such a big problem, even in typed systems, that the most ubiquitous serialization IDLs, and customer-facing API conventions, don't even allow it.
Removing a field in a data structure is such a big problem, even in typed systems, that the most ubiquitous serialization IDLs, and customer-facing API conventions, don't even allow it.
As far as serialization IDLs and API conventions go, they have the very special constraint of having to provide both forward and backwards compatibility across multiple applications, making them a very poor universal example.
As an example, I was once refactoring a Java system. The compiler was happy after about a day, the unit tests after three days.
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.
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.
Now I perfectly understand the feeling that people who are used to the safety-net that static typing appears to give have when encountering a code-base without types. I have the same feeling when encountering a code-base without reasonably comprehensive unit tests (that fail when I poke into the code-base).
The feeling is absolute terror.
I just contend, with reasonably good justification, that this feeling is not particularly justified in the case of static types, because the evidence is just not there.
I haven't checked what the evidentiary status is for unit tests. But then again, I don't make these sorts of categorical claims for unit tests. I just make claims for my experience with unit tests.
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.
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.
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.
Its like a grep, except it can, for example, differentiate between "name" (of user) and "name" (of project)
I don't think you even understood the point at all here. "Types let me make guided and exhaustive changes to code that's much easier to understand due to the types and compiler support"