In the case of generics, the cost of leaving out even simple generics has a high cognitive load cost. I have no problem with taking it slow and conservative; that's a reasonable place for them. But the koans and zealous arguments against generics disrupt the design process.
-
-
Replying to @wycats
I can't say I agree. The cognitive load of any static typing discipline is in mentally modelling the dynamic (unspecified-by-typing) residue; the residue-model gets simpler the fancier the types get, but nonlinearly. Balance is load of residue vs. load of the types themselves.
2 replies 0 retweets 17 likes -
Replying to @graydon_pub @wycats
To me, the nonlinearity is the key here. Residue is already off the cliff of undecidability, so meaningful chunks are quite hard to take out of it. Whereas simpler type systems impose dramatically-less load than more-complex ones (which themselves often fall off same cliff).
1 reply 0 retweets 2 likes -
Replying to @graydon_pub @wycats
Many users have experienced "my program is simple, but type system is so complex that I can't for the life of me get it to typecheck" which is .. a thing you want to reserve for only the gravest / most-pervasive problems if you want anyone to have the patience to use the thing.
2 replies 1 retweet 11 likes -
Replying to @graydon_pub @wycats
My experience is that mostly people who want their simple program to type check are asking for either significantly greater type system complexity or to be able to ignore some aspect of the underlying language (such as concurrency or mutability).
2 replies 0 retweets 7 likes -
Replying to @samth @graydon_pub
Both of which are interesting things to explore. For the first, how can we make those features more usable. For the second, can we allow people to mark their functions to opt out of those features? Yes, and yes, but both require work.
1 reply 0 retweets 0 likes -
Replying to @wycats @graydon_pub
Usually it's two sides of the same coin. Consider List[Object] vs List[Int]. You can fix this seemingly simple problem with ignoring things (a la Typescript) or with complexity (Java wildcards, also other options).
1 reply 0 retweets 0 likes -
Replying to @samth @graydon_pub
Or we can change the defaults around mutability (why does List[] have to be mutable by default) or other tweaks that constrain generics a little and reduce the cognitive load a lot.
1 reply 0 retweets 1 like -
I know that this works somewhat because TS eventually fixed the "ignoring" problem in a strict mode, and using ReadonlyArray<T> pervasively helps a lot.
1 reply 0 retweets 0 likes -
Replying to @wycats @graydon_pub
Sure, but the relationship between Readonly and Array requires lots of complexity.
1 reply 0 retweets 0 likes
It's a different type that is missing all of the mutation methods, and which normal arrays can be cast into.
-
-
Replying to @wycats @graydon_pub
Sure, but that cast is either unsafe or a special case in the type system or supported by a lot of type system complexity.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.