4 ms·
>This is better than a segfault, but it's still a crash. Strong vs weak types is orthogonal to whether there's a crash or not. The crash is because the types a
by coldtea 9y ago
>This is better than a segfault, but it's still a crash.
Strong vs weak types is orthogonal to whether there's a crash or not. The crash is because the types are dynamic (vs static) which is a different axis than strong/weak.
- deleted 9y ago[deleted]
- willtim 9y agoThere 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 9y 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 9y 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 9y 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 9y ago>The classification is established terminology in Computer Science No. It is terminology used by the dynamic language communities, not by academics.
- coldtea 9y 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