Unable to load image

I Don’t Enjoy Writing PHP Anymore :!marseysoycry:

https://medium.com/@davert/why-i-dont-enjoy-writing-php-anymore-aee8a85ca8aa

Why I Don’t Enjoy Writing PHP Anymore | by Michael Bodnarchuk @davert | Oct, 2022 | Medium

It was my first web-development language and the first programming language I was paid for. And I know some shit about maintaining PHP libraries. PHP development nowadays is bumping versions, updating types, and tests, and getting out of cross-dependencies conflicts.

Let’s imagine this situation

I have my own library MyLib that is expected to support PHP 7.4 and PHP 8+ at the same time. As MyLib author I can either drop 🤠 Client #1 and make a major release not because I introduced some breaking changes but because I bumped dependency of coollib.

Now imagine what happens if coollib has also dependencies… And so on…

However, PHP engine treats them differently.

So here are two fundamental problems we have in modern PHP

If either of these won’t be a problem, we would not get into dependency heck. Problem #1 was solved in In #NodeJS. So in NodeJS context, different versions of the same library with different signatures of methods can live together. Using types in the ecosystem and getting into dependency conflict was not an expected outcome of introducing more and more incompatible types into the engine.

Libraries tend to add more and more type changes with breaking compatibility in interfaces every year. Anyway, we can’t force maintainers to keep on old interfaces, right?.

So let’s sum up

While PHP still keeps ugly array_* str* functions from 90s, it breaks compatibility in the ecosystem with every new release. So you get stuck with the lowest PHP version of any of your dependencies. So let’s get back to me, a library author who has a library that just works. 🤓 Client #2 upgraded their app and wants me to upgrade my code as well.

🤠 Client #1 could not get an upgrade yet and wants to use MyLib. Actually, that enterprise client may be supporting MyLib with donations or paying me for consultancy. As an author of a general-purpose library, I will need to maintain a library with versions for all currently used PHPs. But we can’t pay them for a month just to make your shitty MyLib be installed on our application.

It happens because the PHP engine does not keep the compatibility of interfaces between releases, because PHP libraries upgrade to the most modern features, and because we share the global namespace of loaded classes. As a library maintainer, I need to balance upgrades, create bridges between different libraries and always test for compatibility with other dependencies.

27
Jump in the discussion.

No email address required.

Wtf is Client #1 and Client #2??? Isn't that you? Can't you decide which PHP you want to use? I'm not sure what PHP is.

Jump in the discussion.

No email address required.

PHP is short for cannibalism. The clients are the people he is planning to eat

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.