[1] http://www.ybrikman.com/writing/2015/02/06/are-static-typing...
PEP 0484 – Type Hints is accepted
51–60 of 75 posts
Re: PEP 0484 – Type Hints is accepted
#52So now two popular dynamic languages have type hinting of a kind: Python (unenforced annotations) and PHP (declarations). Great!
I encourage all use of the type system to ensure program correctness, but once you've had Hindley-Milner inference, it's hard to muddle along with something like this.
Re: PEP 0484 – Type Hints is accepted
#53Earlier quoted context omitted.
It really is. Since using Haskell, the type systems in the mainstream languages I've used have seemed sorely lacking.
Though make the type system sufficiently more expressive than Haskell's and you have to give up on type inference again... Though maybe you could restrict how expressive the type system is on something like a module (Haskell module) level, so that you can have type inference if you give up on some power? I don't know.
Re: PEP 0484 – Type Hints is accepted
#54Earlier quoted context omitted.
Though I agree with your sentiment, I must mention that there is nothing "weak" about Python's type system. You likely meant "dynamic", not "weak". See here: wiki.python.org/moin/Why%20is%20Python%20a%20dynamic%20language%20and%20also%20a%20strongly%20typed%20language
Yep, thanks.
Re: PEP 0484 – Type Hints is accepted
#55Earlier quoted context omitted.
Though I agree with your sentiment, I must mention that there is nothing "weak" about Python's type system. You likely meant "dynamic", not "weak". See here: wiki.python.org/moin/Why%20is%20Python%20a%20dynamic%20language%20and%20also%20a%20strongly%20typed%20language
Python's type system is weak whether they self-identify that way or not. Types are implicitly converted in a variety of cases, notably True-ness. Meanwhile, runtime type identity is kind of meaningless; classes and individual objects can have their behavior meaningfully changed at runtime. The most you can say about any variable in Python is that it is a descendant of 'object' or else some primitive type.
Re: PEP 0484 – Type Hints is accepted
#56This is a tragedy, as it forces comments to contain syntactic value.
Re: PEP 0484 – Type Hints is accepted
#57Earlier quoted context omitted.
Yeah, isn't that amazing? I really think this "type" idea is a good one. I wonder if other languages have thought about following Python's lead and adding a type system.
Would you like to reconsider your tone?
Maybe you should reconsider yours?
Re: PEP 0484 – Type Hints is accepted
#58Earlier quoted context omitted.
Python's type system is weak whether they self-identify that way or not. Types are implicitly converted in a variety of cases, notably True-ness. Meanwhile, runtime type identity is kind of meaningless; classes and individual objects can have their behavior meaningfully changed at runtime. The most you can say about any variable in Python is that it is a descendant of 'object' or else some primitive type.
If Python's `if` is weakly typed, then Rust's `for` and `.` are weakly typed. Few would say that, though.
I've definitely been bitten by this before, accidentally passing in a book parameter instead of an int, and having some math work initially and then blow up months later.
Knuth argues against this kind of implicit bool to integer conversion in Concrete Mathematics.
Re: PEP 0484 – Type Hints is accepted
#59The way I see it, if you find yourself in the situation where explicit type checking is important, there's probably something wrong with your process or team. Either your are not testing properly, or your team's mindset is more adjusted to another language.
The danger I see with this becoming widespread is Python becoming somewhat like C++ where it's very easy to come across code one can't easily read because it uses a different subset of features than you're used to. This sort of "language accents" so common in human languages is something that should be avoided in computer languages, IMHO.
Re: PEP 0484 – Type Hints is accepted
#60Earlier quoted context omitted.
If Python's `if` is weakly typed, then Rust's `for` and `.` are weakly typed. Few would say that, though.
One place where Python is pretty weakly typed is going the other way, where it accepts things like: true + true * 2 - false / true, even outside of if statements. I've definitely been bitten by this before, accidentally passing in a book parameter instead of an int, and having some math work initially and then blow up months later. Knuth argues against this kind of implicit bool to integer conversion in Concrete Math…
There's a lot of history of languages without a real boolean type using integer 0 and 1 as the sentinel values indicating false-ness and true-ness.
And Python, in a nod to that, implements bool as a subclass of int, of which only two instances can ever exist (with False having a value of 0 and True having a value of 1).
So this isn't weak typing -- isinstance(True, int) is True in Python, and operations like the ones you're mentioning work because of that, for the same reason any other subclass of int would work.