Live data from Hacker News

PEP 0484 – Type Hints is accepted

python.org

41–50 of 75 posts

Re: PEP 0484 – Type Hints is accepted

#41

Earlier 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.

Everything in Python is an object:

    >>> isinstance(type, object)
    true
    >>> T = type('T', (), {})
    >>> isinstance(T, type)
    True
    >>> isinstance(T, object)
    True
    >>> isinstance(T(), object)
    True
    >>> isinstance(int, object)
    True
    >>> issubclass(int, object)
    True
    >>> isinstance(1, object)
    True

Re: PEP 0484 – Type Hints is accepted

#42
post #12

One of the reasons why I use Python 3.x exclusively is for the new function annotations, which allow use of this: https://github.com/prechelt/typecheck-decorator This allows me to write Python in a design-by-contract style with full, rich runtime type checks. My bug count has gone down dramatically, and when I do find a bug it's virtually always via a typecheck exception.

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.

Yeah, imagine how retarded the type systems of the popular static typed languages were, that lead to such a baby-booming of dynamic languages. People were traumatized so hard that took years to reconsider a middle ground.

Re: PEP 0484 – Type Hints is accepted

#43
post #42
post #12

Earlier 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.

Yeah, imagine how retarded the type systems of the popular static typed languages were, that lead to such a baby-booming of dynamic languages. People were traumatized so hard that took years to reconsider a middle ground.

I think it's always been about how annoying it is to write out types.

If you look at how popular go is among pythonistas, it kind of shows that the issue was really a lack of type inference more than anything else.

Re: PEP 0484 – Type Hints is accepted

#44
post #43
post #42

Earlier quoted context omitted.

Yeah, imagine how retarded the type systems of the popular static typed languages were, that lead to such a baby-booming of dynamic languages. People were traumatized so hard that took years to reconsider a middle ground.

I think it's always been about how annoying it is to write out types. If you look at how popular go is among pythonistas, it kind of shows that the issue was really a lack of type inference more than anything else.

I share the same opinion, even sth as simple as TI makes things so much better. It's not only about writing but also reading the code.

A good summary what's wrong with the type systems of the java era: http://www.slideshare.net/ScottWlaschin/c-light

Re: PEP 0484 – Type Hints is accepted

#46
post #27

Earlier quoted context omitted.

I agree that Java is painful to use, but why is type erasure the annoyance that you need to single out? Haskell does type erasure as well.

I feel like that comment is a little disingenous or at least needs a caveat after reading this[0]. I know that casts are almost never needed in Haskell code whereas I needed them in my last Android application (correct me if there's another way). 0: http://stackoverflow.com/questions/12468722/does-haskell-era...

That stackoverflow answer explains Haskell does type erasure. No, it doesn't work exactly the same as in Java, but nobody claimed it did. The OP claimed Java's type erasure annoyed him, while also claiming he had used Haskell a lot. I merely pointed out Haskell also erases types.

I cannot advise you on your Android application without knowing what you're trying to accomplish.

Re: PEP 0484 – Type Hints is accepted

#47
post #18

Earlier quoted context omitted.

No, but let me clarify. Bolting on a form of type checking to a weakly typed language seems orthogonal to the nature of a language like Python. If you find yourself saying "I wish I had a type system in this code base, its getting pretty big and a compiler that does type checking at compile time sure would make my life easier" maybe you should think about using a more appropriate tool. I use Python a lot and it has i…

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

#48
post #42
post #12

Earlier 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.

Yeah, imagine how retarded the type systems of the popular static typed languages were, that lead to such a baby-booming of dynamic languages. People were traumatized so hard that took years to reconsider a middle ground.

That's an interesting way of looking at it.

Re: PEP 0484 – Type Hints is accepted

#50
post #18
post #14

Earlier quoted context omitted.

Would you like to reconsider your tone?

No, but let me clarify. Bolting on a form of type checking to a weakly typed language seems orthogonal to the nature of a language like Python. If you find yourself saying "I wish I had a type system in this code base, its getting pretty big and a compiler that does type checking at compile time sure would make my life easier" maybe you should think about using a more appropriate tool. I use Python a lot and it has i…

I agree with everything you said here. Personally, I wish this had been your original post. It seems like a helpful jumping-off point for constructive conversation.
Post reply on HN