3 ms·
I see this being downvoted over the difference between dynamic typing and type inference. I feel this is unjustified. The example shows what can go wrong with t
by nuancebydefault 3y ago
I see this being downvoted over the difference between dynamic typing and type inference.
I feel this is unjustified. The example shows what can go wrong with type inference, which is in fact a feature of dynamicly typed languages (even though it is not explitly called type inference in that context).
- steveklabnik 3y ago> programmers tend to read essays until they getting to the first line they disagree with and then tweet about it, like a compiler https://twitter.com/tef_ebooks/status/1108101434141298695 https://twitter.com/tef_ebooks/status/1108101434141298695 I suspect many people didn't get past the first five words. That said, I agree with you that the point is more legitimate, but I don't think it's a particularly strong argument.
- IshKebab 3y agoType inference isn't really a feature of dynamically typed languages any more than emergency stop is a feature of hand saws. It isn't applicable because there are no static types to infer. Type inference can in some cases lead to type confusion in a way that can also happen with dynamic types. In my experience it is extraordinarily rare, especially in languages with only limited or local type inference like Rust or C++.
- nuancebydefault 3y agoToday I learned: don't call type introspection type inference if you do not want your HN popularity to decrease.
- IshKebab 3y agoType introspection is another thing entirely! That's basically reflection, which is nothing to do with anything mentioned so far. To be clear: * Dynamic typing: types are not known at compile time * Static typing: types are known at compile time and written down in the source code. * Static typing with type inference: types are known at compile time and inferred rather than being explicitly written down * Dynamic typing with type inference: nonsensical; not a thing * Type introspection: types can be inspected by code at runtime. Unrelated to any of the above. Can be found (or not found) in both dynamically typed and statically typed languages.
- nuancebydefault 3y agoThanks for the overview. I agree with all, except for the "has nothing to do with" claim. > Dynamic typing: types are not known at compile time. That is just a top level description of a feature, the tip of the iceberg. What is needed for a language to support dynamic typing? The answer is not "has nothing to do with x" where x is any of the above features. Also a lot of types are known at compile time even if your language supports dynamic typing. Also "compile time" is a vague term for an interpreted language, as the machine compatible code is generated at run time.