Image Credits: Ben Griffiths, Unsplash
It is said that there is no bad language if it allows you to program the necessary patterns to develop most of the existing solutions. While this is true, PHP, despite its improvements over the years, has failed to provide greater efficiency, performance, and native API implementations than most other scripting (and non-scripting) languages.
Let's compare it in its context, with the most used scripting languages today:
Also if you need it, you can have static typing with TypeScript (non-existent option -for now- in PHP for example) plus the community, number of libraries, integrations, SDKs etc is much higher.
PHP outperforms Ruby in resource efficiency now as it has been for a long time.
Some background on PHP: The initial OOP implementation in PHP happened in PHP 3.x and it wasn't until PHP 5 that the implementation was comparable to other languages (again, it was late) and the same thing is happening to it with the inclusion of functional tools whose usefulness has come to the fore in recent years.
In PHP there was an attempt to create desktop apps with it long time ago, it failed due to lack of efficiency. In the end it would start an apache and run the code there if I'm not wrong, can't even remember the name of it, neither I know if there have been subsequent attempts.
Please note that any language can be a cross-platform language if a platform-specific interpreter is released.
- Electron for desktop applications
- React Native, ionic and cordova for smartphone Apps (iOS and Android)
- Three JS for video games
Therefore, in the TOP scripting languages, the pole would look like this:
2- Python (If we talk about ML, it would be in Top 1).
4- PHP (if it had Lambdas and covered other deficiencies, it would be in position 3 over Ruby).
For all these reasons, PHP has been relegated mostly to the maintenance and development of plugins or modules for CMS (wordpress, prestashop, etc. which covers the ~50% of the public web currently) and less and less to build microservices or create webApps, because despite being possible, it is not the best option by far.
If you are planning to learn PHP the question would be "Which target do you pursue?"
If you are going to base your business in CMS plugins/themes then yes, PHP is your language.
If you are planning to do ML, then better pick Python and if you also want to code any website or web app, you can pick Django as python framework to build websites.
To simplify, we can say that PHP is not dead because there are nearly more than 50% of the websites that use PHP (mostly CMS) as their back-end language. But the majority of new projects are using other technologies like Node JS due to numerous of reasons which make it more efficient than PHP.