Remix.run Logo
account42 7 days ago

So they are consistent because they are consistently inconsistent??

There isn't a good reason for PHP to have inherited C's issues here.

goykasi 7 days ago | parent [-]

In the early days of PHP, it relied heavily on wrapping the underlying C libraries and preserving their naming conventions.

https://news-web.php.net/php.internals/70950

gbalduzzi 7 days ago | parent [-]

And that was fine in the early days, absolutely.

We are not in the early days though, and in many other aspects PHP evolved greatly.

goykasi 7 days ago | parent [-]

What are the benefits? Code completion, AI agents, etc will handle it for you. No one's life is falling apart because the param ordering is more similar to C than a blog article complaining about it decade ago. Php devs have had up 30 years to learn the difference. Are C devs complaining about this?

If we want to change the param order of str/array functions for php, I think we should start with fixing the C libraries. That seems like a better starting point. The impact will certainly be more beneficial to even more developers than just php.

gbalduzzi 7 days ago | parent [-]

Because it would be more predictable, easier to memorize, less verbose, easier to use for developers coming from other modern languages and more comfortable to work with.

The fact that they are chaotic since 30 years ago is not a valid reason for keeping them chaotic right now.

Also, I'm not even arguing they should change the existing functions, that would break all existing code for almost no reason.

I think they should "simply" support methods on primitives, and implement the main ones in a chainable way:

"test string"->trim()->upper()->limit(100);

[0,1,2]->filter(fn ($n) => $n % 2 === 0)->map(fn($n) => $n * 2);

I would love this so much