2 ms·
What I have seen in the wild is that in dynamic languages programs end up being "stringly" typed, where a mistyped string in the program results in an error, an
by bgorman 6y ago
What I have seen in the wild is that in dynamic languages programs end up being "stringly" typed, where a mistyped string in the program results in an error, and programs needlessly rely on array positioning.
ML languages that support variants eliminate these unnecessary errors are no cost to runtime performance.
What problems have you encountered where a ML system couldn't represent things better than primitive type system? The two things that come to my mind are when the program has to accept arbitrary user input (strings), and writing an extremely expressive program i.e. a lisp interpreter with support for variable argument length functions. Even in these cases, I think the guarantees around the messy sections help with refactoring and my general sanity.
- dwohnitmok 6y ago> What problems have you encountered where a ML system couldn't represent things better than primitive type system? I assume you mean a primitive type system to be a strict subset of an ML type system? So in that case the answer in theory is clearly negative. The problem is more that ML type systems give you more, and fool you into thinking that's enough to try to use the extra bits, when that's not quite enough. > ML languages that support variants eliminate these unnecessary errors are no cost to runtime performance. Closed variants are fantastic. I love them. I miss them every time I use a programming language without them. What I'm talking about is requirements like making sure that all your matrix dimensions line up (you mention variadic arguments, which is another good one if you're trying to follow a lot of mathematical notation). A lot of ML-inspired statically typed languages let you come really close to making all that work. But are just unergonomic enough to make things painful if you really try to statically verify those things.
- bgorman 6y agoMakes sense, thanks for the explanation.