4 ms·
I have a Python script runs as both Python 2 and Python 3, using runtime checks to determine which methods to call. This sort of thing is much harder in Haskell
by ridiculous_fish 11y ago
I have a Python script runs as both Python 2 and Python 3, using runtime checks to determine which methods to call. This sort of thing is much harder in Haskell.
A more ambitious example: imagine the web with JavaScript replaced by Haskell. Your code compiles and typechecks in your browser, but that doesn't guarantee that it will do the same in mine, or a different version of yours, or tomorrow's new browser. So these static type guarantees are very weak because they only apply to a single runtime environment.
The less control you have over the runtime environment, the more important dynamic typechecks become. You can also have static type checking, but you have to be prepared for the fact that your static types will be different at runtime. This property confounds most languages with static type systems, including Haskell.
- guiraldelli 11y ago> A more ambitious example: imagine the web with JavaScript replaced by Haskell. Your code compiles and typechecks in your browser, but that doesn't guarantee that it will do the same in mine, or a different version of yours, or tomorrow's new browser. So these static type guarantees are very weak because they only apply to a single runtime environment. Wait... What? Are you saying that natural numbers in South America in 1990 century is different from natural numbers in Europe 2010? So how can types be different depending on browsers? Of course, if the browser implements a "compiler" that doesn't follow the basic principles reported in the standard of the language, it'll happen. If some joker wants to call `Int` a `String`, problems will happen. Otherwise, it is not true.
- nickbauman 11y agoAh, that's right. Everyone implements the compiler spec the same way every time, because we live in a perfect world.