Login
You're viewing the ruby.social public feed.

Replies

  • Nov 27, 2025, 10:28 PM

    @lig I really shouldn't engage, but reading "Python make correctness normal" when they chose god awful default behaviour for `match` by just silently falling through if no case is matches is truly the most baffling recent Python decision.

    The only reasonable thing you say is that PHP's IO functions are trash, which is true and nobody would dispute. The rest of it is ... false equivalences without even showing _why_ Rust (a PL 20 years younger, and with a different focus) or Python is better.

    💬 0🔄 0⭐ 5
  • Nov 27, 2025, 10:28 PM

    @lig You `add()` example is probably one of the worst examples you could have come up with... because

    ```python
    def add(a, b):
    return a + b;

    print(add(15, 42));
    print(add(15, 42.6));
    print(add("hello", "world"));
    ```

    All work, so what does `add()` return? Eh idk depends on what you give it I guess? At least PHP would throw a TypeError in the 3rd case because concatenation doesn't use the same symbol as addition.

    💬 0🔄 0⭐ 5
  • Nov 27, 2025, 10:30 PM

    @lig Python is so much more cargo cultish on "no no no your code is not Pythonic" compared to PHP. And Frankly I cannot take anyone that implies Python doesn't make writing bad code easy serious, because it means they have never seen academics write horrendous Python code lol

    💬 0🔄 2⭐ 6
  • Nov 28, 2025, 9:53 AM

    @Girgias @lig You are right, i do think the inclusion of python here is quite strange. But, and i'm steelmanning a lot here, the article explicitly says that pythons defaults lead to readable code, not good code. At least thats my read of it. I don't fully agree with that take either, but its a far more reasonable one, which, if it was made in a different context, wouldn't be that crazy.

    at least the ecosystem in Python seemd to be embracing the optional typing more than what little i know of php.

    I would have liked the article to actually... argue its point a bit more instead of listing supposed qualities in bullet points. I suspect that would have led the author to figure out that Python isn't a great example of what the overall message seems to be.

    The php i have read was probably close to the worst example, a codebase which doesn't use any of the frameworks and just relies on global state etc exactly as the article criticises. I know i'll take Python over that kind of PHP any day, if those were the options. But i'm not saying i have an unbiased opinion there, after all i only know that one awful codebase and have been using Python for years...

    💬 2🔄 0⭐ 0
  • Nov 28, 2025, 12:54 PM

    @laund @Girgias @lig
    From what I understand, the big difference between Python's optional typing and PHP's is that in Python it's optional *even after you write down the types*. You can write completely nonsense types into your functions, and it will all run just fine.

    That's just not true in PHP: if you write down a type, the language gives you a 100% guarantee that the value is of that type at that place in the program. It might automatically cast an incoming value to that type, but it won't let you just skip the check.

    💬 0🔄 0⭐ 0
  • 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
  • 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
  • Nov 28, 2025, 1:48 AM

    @lig Remarkable trolling. Haven't seen anything that dumb since the "fractal" post.

    "The ecosystem largely ignores [types]." Utter BS. Have you even seen PHP code in the last decade? Anything new for years is heavily typed. And types are enforced, unlike python.

    "testing is extra" True of every language. Except maybe Rust.

    "type safety is optional" It's enforced when used, unlike python. And then there's JS.

    I hate how dev.to publishes any old uninformed crap. It's why I don't read them.

    💬 0🔄 0⭐ 0