9
ZioCain
5y

I like how it's lowly becoming more and more a typed language.
Anyway, nice updates, but don't really see much changes overall

https://php.net/releases/8.0/...

Comments
  • 4
    Wow this is surprisingly good
  • 1
    Let's hope to get variable types in the next version.
  • 3
    It's about time, honestly. 🤣

    I will never understand the mentality that answers the question, "hey, how about we let the machine tell you when you're about to run into a predictable failure because of the intent your code conveys," with, "I'd prefer not to."
  • 2
    @SortOfTested Yeah, with modern type inference there really isn't any argument left for dynamic typing
  • 0
    Too late. Those who care moved on a long time ago, and those who don't aren't going to use it anyway.
  • 1
    @iiii Nah, duck typing essentially *is* weak typing and both are horrible

    Just because I have a method next() doesn't make me an iterator. The only entity that can judge whether I am is a human able to read and interpret the documentation which contains vital semantic information not expressible in code
  • 0
    @iiii
    I think he's just discriminating between duck typing and structural typing. Duck typing checks occur at runtime, structural typing performs the same check at compile time.
  • 0
    @iiii @SortOfTested I don't like duck/structural typing whether it happens at compile time for this reason:

    A method signature does not hold enough
    semantic information to judge compatibility

    Can next() return null? Can it return not-null after it returned null? Does it throw exceptions? When? Does it have any significant side effects?

    These are things that you can't express in a signature yet are vital to robust code
  • 0
    @iiii Duck typing and weak typing are very similar though

    Weak typing does implicit conversion while duck typing does implicit interface implementation (for lack of a better term). But in both cases your values are implicitely coerced to different semantics
  • 0
    @iiii Weak typing: A string can magically act like a number

    Duck typing: My object can magically act like an iterator

    In what world are these not similar ideas?
  • 0
    @iiii My object -- which does not explicitely have the interface Iterator implemented -- magically implements that Interface because it has matching methods

    It IS magic because it happens at a distance without your control. That's literally what that means

    And this is exactly what I'm critiquing, and what I have explained twice now but what you have conveniently ignored both times

    **A method signature does not hold enough semantic information to deduce compatibility**
  • 0
    @Z-GOD That's the downside of a badly designed language. When you actually try to fix it (like they do, let's be fair) you HAVE to break backwards compatibility in a major way
  • 0
    @iiii Yes, but the problem I'm getting at is that in one case you are explicitely and positively asserting that your class follows the iterator interface semantics as required in the docs, where as in the other case it's just implicitely assumed that it'll be alright because the method signatures happen to match
  • 0
    @SortOfTested I’ve never heard a more spot on statement about the strange mentality of proponents of weakly typed systems :D

    Very nice!
Add Comment