5 ms·
Yes I agree type inference is wonderful! But when the underlying type-system is just C# I feel like I'm given a half-assed solution. What good is having a int
by jeremiep 10y ago
Yes I agree type inference is wonderful! But when the underlying type-system is just C# I feel like I'm given a half-assed solution.
What good is having a int type if you can't limit its range?
I'm not going to maintain BOTH static types and tests. The ROI is way too low on that and won't even come close to guarantee robustness.
Assertions over composable predicates gives me much more out of the time invested to write it. They are right there in the code at runtime, not separate like unit tests or in a different phase like static types.
- wvenable 10y ago> What good is having a int type if you can't limit its range? Well then you don't have to test what happens when someone passes a string, an object, or a boolean. Most dynamic languages will silently convert many of these values into an int and produce incorrect results. > I'm not going to maintain BOTH static types and tests. You have to maintain documentation and you have to maintain tests and you have to maintain assertions for the implied types of your functions anyway so you might as well make them explicit in the code.
- jeremiep 10y ago> Well then you don't have to test what happens when someone passes a string, an object, or a boolean. That's useless, I still need to test the value's range which implicitly checks the type. > You have to maintain documentation and you have to maintain tests and you have to maintain assertions Not if I can generate most of it from the specification data.
- wvenable 10y ago> What good is having a int type if you can't limit its range? Most types in the program aren't ints anyway; they're interfaces. If I want to have a range-limited value, I could just create a new type for it.