8 ms·
Python is not "strongly typed". Please don't repeat this phrase near management folk. Python just gives good error messages when it crashes at runtime, e.g. "ex
by willtim 8y ago
Python is not "strongly typed". Please don't repeat this phrase near management folk. Python just gives good error messages when it crashes at runtime, e.g. "expected an Int but got a String". This is better than a segfault, but it's still a crash.
Call it "strongly tagged" if you like, but "type" unqualified should mean static type. Even "dynamic type" is a marketing hijack of the word type.
Professor Robert Harper takes the same position: https://existentialtype.wordpress.com/2011/03/19/dynamic-languages-are-static-languages/ https://existentialtype.wordpress.com/2011/03/19/dynamic-lan...
- coldtea 8y 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 8y ago[deleted]
- willtim 8y 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 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
- riquito 8y agoWell, it is - https://en.wikipedia.org/wiki/Strong_and_weak_typing https://en.wikipedia.org/wiki/Strong_and_weak_typing - https://stackoverflow.com/questions/11328920/is-python-strongly-typed https://stackoverflow.com/questions/11328920/is-python-stron...
- willtim 8y agoFrom your Wikipedia link: "Generally, a strongly typed language has stricter typing rules at compile time, which imply that errors and exceptions are more likely to happen during compilation"
- dralley 8y agoPython is strongly typed. It is also dynamically typed, and many people get the two confused.
- willtim 8y agoThe confusion is no doubt intentional in order to make dynamic languages sound safer than they really are. There really is only one type: PyObject.
- acdha 8y agoThis statement wouldn't be helpful even if wasn't incorrect. You clearly don't like Python but accusing other people of malice for not sharing your personal taste is not going to accomplish whatever you believe it will.
- deleted 8y ago[deleted]
- willtim 8y agoThis is about being open and honest to stakeholders about Pythons strengths and weaknesses. Sure, I won't ever get the terminology used in your community to change, but at least you will know that there are people who find it rather uncomfortable and disingenuous.
- acdha 8y agoDisingenuous is lying about people’s motives to make your opinion seem more like a truth. It’s okay not to understand Python or typing as well as you think but that should be a chance to learn rather than your cue to accuse people of malice for giving the world free software.
- willtim 8y agoGo read the link I posted by Professor Robert Harper before accusing me or anyone else of not understanding type theory. Whether you like it or not, technology does compete for mindshare. Haskell and OCaml are also free software.