4 ms·
There is no static/dynamic axis for types. A dynamic "type" as you call it, is really a runtime tag. All languages are static languages. "Dynamic" and "dynamica
by willtim 8y ago
There is no static/dynamic axis for types. A dynamic "type" as you call it, is really a runtime tag. All languages are static languages. "Dynamic" and "dynamically typed" are IMHO, marketing terms. There's nothing that "dynamic" Python can do that I cannot do in a typed language using runtime tags, string keys and variants.
- viraptor 8y agoStatic/dynamic and weak/strong typing is about the language semamtics and the runtime. You can't reduce the description the way you do, because for every language we end up with: there's nothing I can do in X that I can't do in untyped ASM, therefore everything is untyped. Or go down to either lambda calculus or logic gates. Either works. What the language provides matters. For code like "1"+1 you have 4 main options: - strong static - doesn't compile/start due to type error - weak static - returns "11" and expression is known to result in a string at compile time - strong dynamic - crash/exception at runtime - weak dynamic - returns "11" at runtime, but the type is attached to the value, not the original expression
- willtim 8y agoYour classification is based on a trivial expression involving primitive types. What would most Python code do if one tried to append a SQL query to a filepath? Since both will likely be represented by strings, it will return garbage, "weak" in your definition. Whether it crashes or not in any particular implementation is not a feature of the language.
- coldtea 8y ago>Your classification is based on a trivial expression involving primitive types. It's not "his classification", just his example. The classification is established terminology in Computer Science. >Since both will likely be represented by strings, it will return garbage, "weak" in your definition. It's not his definition, and it's not weak in this case. Weak is not about getting garbage or not, it's about the semantics of a behavior. It could be that the result of the weak behavior is exactly what one wanted (e.g. to add a string to an SQL statement -- I might be adding together SQL statements and text about them to produce a book on SQL with my script). In any case, the SQL statement is a string in Python, not its own type, so the result will not be weakly checked, it will be strongly checked as what it is (a string) -- Python will do what it should.
- willtim 8y ago>The classification is established terminology in Computer Science No. It is terminology used by the dynamic language communities, not by academics.
- coldtea 8y agoYeah, I guess all those papers that discuss strong and weak typing weren't written by "real" academics... For example: http://www.lucacardelli.name/Papers/TypefulProg.pdf http://www.lucacardelli.name/Papers/TypefulProg.pdf https://dl.acm.org/citation.cfm?id=97964 https://dl.acm.org/citation.cfm?id=97964 https://www.usenix.org/legacy/event/sec09/tech/full_papers/robertson.pdf https://www.usenix.org/legacy/event/sec09/tech/full_papers/r... https://dl.acm.org/citation.cfm?id=382281 https://dl.acm.org/citation.cfm?id=382281 https://ieeexplore.ieee.org/abstract/document/660187/?reload=true https://ieeexplore.ieee.org/abstract/document/660187/?reload... https://dl.acm.org/citation.cfm?id=38823 https://dl.acm.org/citation.cfm?id=38823 https://patents.google.com/patent/US7086041B2/en https://patents.google.com/patent/US7086041B2/en https://link.springer.com/chapter/10.1007/978-3-642-03359-9_2 https://link.springer.com/chapter/10.1007/978-3-642-03359-9_... https://ieeexplore.ieee.org/abstract/document/4085614/ https://ieeexplore.ieee.org/abstract/document/4085614/ https://ieeexplore.ieee.org/abstract/document/287604/ https://ieeexplore.ieee.org/abstract/document/287604/ https://dl.acm.org/citation.cfm?id=2635922 https://dl.acm.org/citation.cfm?id=2635922 https://link.springer.com/chapter/10.1007/3-540-54444-5_83 https://link.springer.com/chapter/10.1007/3-540-54444-5_83
- willtim 8y agoThat looks like a random list of papers. Which one are you claiming defines or even discusses "strong" or "weak" typing? AFAIK those terms have no real definition in type theory.
- viraptor 8y agoYou're moving goalposts. You said academics don't use the terms - you were given examples that do so. None of them need to define it - if you're interested, you can do that research. Those terms don't have definitions in type theory and that's ok. Systems defined in the type theory deal with very explicit, theoretical analysis that usually maps well only to static-strong implementations.
- acdha 8y agoHow about a type error, which what actually happens? from pathlib import Path p = Path(".") print("some random string" + p) If you store typed data as generic strings, of course, it’ll work but no language has an AI which will prevent you from being lazy about that.
- willtim 8y agoPerhaps filepath was a bad example for Python, as it has assertions. Zenhack actually made the same point and explained it better than me. Your runtime assertions (what you call "strong dynamic types") are a feature of the libraries you are using and a few built-in primitives. Python does not really have any facilities to talk about types. Using strings as in my example, would be "weak typing" in your terminology, but as you said, this is possible in any language, even Haskell. Therefore I fail to see how strong/weak is a language property. We are therefore left with static and "dynamic types", which Robert Harper argues should be statically typed and statically unityped.
- coldtea 8y ago>Therefore I fail to see how strong/weak is a language property. That much is a given...