3 ms·
It's not just about type information; in fact, having type information doesn't mean anything in its own right. The point is in static analysis, which can be man
by BerislavLopac 4y ago
It's not just about type information; in fact, having type information doesn't mean anything in its own right. The point is in static analysis, which can be mandatory (most statically typed languages), or optional (e.g. Python).
I am not aware of any static languages that check the types at runtime (if such languages exist, please mention them in the comments); however. they require a static analysis to happen at compile time, and refuse to compile if the analysis breaks at any point. Python, on the other hand, allows to be compiled and executed without ensuring the type safety first; however it can still be statically analyzed, even without explicit type annotations, using an optional tool such as mypy (which can infer types quite correctly in many cases).
- twhitmore 4y agoEclipse IDE (Java) can run your project, even if it doesn't all compile. I expect this must be fairly common among IDEs with incremental compilers. You can run valid sections & gradually progress the complete correctness. No need for a dynamic language. With static typed language, reliability and refactoring are easy. I'm scripting some small scripts in Python this week but every time I come back to it, I am reminded how not actually very good it is.
- xmcqdpt2 4y agoMost languages do some checks at runtime. This is the strong / weak typing dichotomy (which is different from the static/ dynamic one). For example, Java will throw an exception at runtime if an object is cast (using .asInstanceOf) to an incompatible class. Python throws if you add an integer to a string. Both of those languages are strongly typed. On the other hand, C has no runtime checks whatsoever. If you add a number to an array the program will happily move the array pointer and maybe overflow, but even that won't cause a runtime failure every time.
- BerislavLopac 4y agoThis is precisely my point. In the examples above, the checks are implemented in specific cases, and not universally; so the whole point of static typing is the analysis, and not runtime safety.