5 ms·
You are making my point, I'm very much in favor of primitive or very simple types. More complex types typically have a bad cost to benefit ratio. And it's quit
by jstimpfle 10y ago
You are making my point, I'm very much in favor of primitive or very simple types. More complex types typically have a bad cost to benefit ratio.
And it's quite doable to get by even without these simple-type annotations. Just put some assertions at strategic locations. Of course there still is some amount of debugging involved. On the other hand development was much cheaper at other places, and once it works you can be reasonably confident that an int will not turn into a string overnight.
- vosper 10y agoThe problem with assertions is that sometimes they mean people get woken up in the middle of the night for an issue that would have been caught hours/days/weeks before by a statically-typed language. If you don't have 100% test coverage in Python you just can't rule that possibilility out. I say this as a full-time Python engineer and I've been woken up at 3am by things that slipped through testing and would have been caught in (say) Java or C#. Now, it is arguable whether it's worthwhile to take that chance to make development quicker and more flexible. I can definitely see that. Also, if you have to wait a long time for the compiler then that might actually be a loss in aggregate. It does suck trying to refactor large Python codebases though. Running and fixing the tests over and over until errors go down to zero is no fun.
- crdoconnor 10y ago>The problem with assertions is that sometimes they mean people get woken up in the middle of the night for an issue that would have been caught hours/days/weeks before by a statically-typed language. If you don't have 100% test coverage in Python you just can't rule that possibilility out. I say this as a full-time Python engineer and I've been woken up at 3am by things that slipped through testing and would have been caught in (say) Java or C#. For me, carefully placed assertions combined with a comprehensive (but not 100%), test suite nearly always means A) catching the exception with a test or B) a clear production error that indicates a problem with the production environment. I've been woken up plenty by poorly written Java that has had its type system intentionally weakened by terrible coders, meaning lots of detective work. It's a fallacy is that dynamic automatically means weak and static automatically means strict. Assertions aren't just useful in dynamically typed languages. Java would benefit from using them as well.
- adwn 10y ago> You are making my point, I'm very much in favor of primitive or very simple types. More complex types typically have a bad cost to benefit ratio. What is a "simple type" in your eyes? Primitive types plus aggregates and arrays? What if your data structure is actually complex? Do you just stuff it in a hashmap?
- jstimpfle 10y agoPrimitive types plus basic containers mostly. Anything else is just ad-hoc stuff (like algorithms) that should be properly encapsulated, so its representation in a static type system has less utility.