4 ms·
> The usefulness of types is in them describing the input/output dependencies in your code. I agree, but I find types way too weak in that respect. Its not eno
by jeremiep 10y ago
> The usefulness of types is in them describing the input/output dependencies in your code.
I agree, but I find types way too weak in that respect. Its not enough to know a function accepts ints; I want to know its range as well.
I spent so many weeks hunting down overflow and out-of-range errors and null pointer exceptions that types feel like an illusion of robustness at best.
> Now, how will immutability, hostility to state or unit testing help you with this question?
Not that much, I'll give you that. But the same is true for a function whose range was 1-20 being refactored into a range of 1-10; types won't catch that.
I used to like types, then testing, now I'm looking at specifications I can write once, compose and then generate assertions, documentation, test data and everything else from. Its by far the best ROI of the three.
- spion 10y ago> Its not enough to know a function accepts ints; I want to know its range as well. Types actually help with this too. Instead of changing the possible range of a thing, change its name too: the compiler will quickly let you know of all the places that depend on it. Now you know what to check.