Login
You're viewing the ruby.social public feed.
  • Nov 28, 2025, 1:00 PM

    @imsop @Girgias @lig Well, yea. Almost always you'd do the checking using a static type checker. The fact it still runs with wrong types is what allows gradual/partial typing of libraries, which i think is a big factor for adoption, hence the ecosystem embracing it more.

    💬 2🔄 0⭐ 0

Replies

  • Nov 28, 2025, 1:17 PM

    @laund @Girgias @lig
    Yes, there's a one-time compatibility cost to adding types in certain places. Mostly, that only manifests in library code that expects the user to extend a class and overload a method, because of substitutabilty checks. Or, I guess, when the language learns to check more complex types, but you want to support users who haven't upgraded yet.

    Of course, you can instead add type information in comments, where optional information belongs, and static analysis tools will read it just fine.

    But with Python's approach, you don't get a choice: you can only add type hints that you can't enforce, so still have to write code knowing that the user can pass in garbage and will probably blame you when everything breaks. Or vice versa, use a library which has added type hints but not actually checked them, so occasionally just lies.

    💬 0🔄 0⭐ 0
  • Nov 28, 2025, 1:35 PM

    @imsop @Girgias @lig Yeah, comments would work. But there are tools that utilize the actual type hint syntax which python added at runtime, since its still available. Theres even full runtime type checkers, though its a less popular option, more commonly theres libraries which use type hints for individual features.

    Part of the issue with introducing typing to any language which didn't have it before is that you're going to have features which theres no (reasonable) way to cover with types. It sounds like PHP types don't have some kinds of complex types yet? Relying on static checkers allows them to iterate on complex types and ways to handle them without having to implement it at runtime, which might be why, if i understood correctly, PHPs typing doesn't go as complex (generics? higher-order functions?).

    Of course you're right that in python, libraries being wrongly typed can be an issue. But because theres no actual compatibility cost to introducing or changing types, maintainers seem to be more open to changes and corrections. If changing types can break user code, you have to be more careful about doing so, which isn't great when the language wasn't designed from the ground up for strict types.

    💬 1🔄 0⭐ 0
  • Nov 28, 2025, 2:21 PM

    @laund @Girgias @lig
    To be honest, I've not experienced the reluctance to add types that you're talking about. In my experience, it's mostly a case of "we require minimum PHP version X now, so have added all the type declarations available in that version".

    The problem with generics is slightly more complex: how to support them properly at runtime without a big cost in performance and engine complexity. Even fully typed languages struggle with that, e.g. whether they're visible to reflection and dynamic code, or erased by the compiler after a static check.

    Some experimental progress has been made, but for now, they live in comments (specifically, docblocks) where static analysers like PHPStan see them, but they won't conflict with a more integrated solution in the future.

    💬 0🔄 0⭐ 0
  • Nov 28, 2025, 7:03 PM

    @imsop @Girgias@phpc.social @lig

    Its very possible that the cross-section of PHP i've seen has given me a wrong impression about the adoption of types in PHP.

    💬 0🔄 0⭐ 0
  • Nov 28, 2025, 4:38 PM

    @laund @imsop @lig You cannot compare Python with static analysis against PHP without it. Because once again, the claim of "no one runs Python without using a static type checker first" is just BS.

    Because the _obvious_ rebuttal is: no reasonable PHP dev wouldn't first run a static type checker.

    Python is a decent PL, but the obsession of some Python people to try to "one up" PHP is frankly baffling. Python is slower by a 2x factor, and only has started to improve with huge financing from MS.

    💬 1🔄 0⭐ 0
  • Nov 28, 2025, 6:58 PM

    @Girgias @imsop @lig I don't know in which world you think we live, where strawmanning that hard gets you anything other than blocked, but its not the same i occupy.

    💬 0🔄 0⭐ 0