DEV Community

Cover image for Underestimated PHP
Alexander Dyriavin
Alexander Dyriavin

Posted on

Underestimated PHP

After browsing Reddit and Twitter I`ve noticed that the majority of developers underestimate PHP as a language.

As with any programming language or technology, PHP comes to us with its pros and cons, however, it doesn't change the fact that PHP is widely used.

PHP was changing over the years, but the last year provided a new breath to the language, seeing such effort from different people, I highly disagree with the opinion that "PHP is dying".

Just a recent finding shows that with each release, PHP as a language involves and brings new features to the community.
With combination with such great tools as:

  1. Static analysis or Laravel-lovers
  2. Coding Standards Fixer
  3. Mess detector
  4. Analysis violations of a defined coding standard

Some of the references:
https://github.com/php/web-php/pull/602 - redesign the PHP home page, to make it look more up-to-date with UI/UX trends.
https://wiki.php.net/rfc/auto-capture-closure - Short Closures 2.0
https://thephp.foundation/blog/2022/06/30/php-core-roundup-3/ - Detailed report on progress from PHP-foundation collective

If you find have such post interesting, please share it with me.

Top comments (24)

Collapse
 
pyrsmk profile image
Aurélien Delogu

I hear the axiom "PHP is dying" since ten years. But I think the vast majority that shout it do not even know PHP. In fact, PHP is even more complete and powerful than Javascript, with a less messy ecosystem. But eh! Haters gonna hate.

Collapse
 
chuniversiteit profile image
Chun Fei Lung

It’s a good thing that all those people who keep saying that “PHP is dying” aren’t doctors. Imagine your doctor telling you that you are “dying”, only because you’re no longer the coolest kid in high school… (now that you’re studying at a university)

Collapse
 
dyriavin profile image
Alexander Dyriavin

Good one :D

Collapse
 
dyriavin profile image
Alexander Dyriavin

I personally find it something like this:
People learn JS or Python - because their learning threshold is lower comparing them to PHP. (Based on Stack-overflow survey )

Since both Python and JS - have less elegance in Object-oriented architecture and simpler syntax than PHP, for some people it might be quite a challenge to get used to PHP, which leads to hate.

Collapse
 
pyrsmk profile image
Aurélien Delogu

Probably. And also it's a big trend, there's always a black sheep somewhere so people can just beat it without any reason, ahah. But, let's say it, the PHP API should be revised IMO.

Anyway, I really love recent additions in PHP 8.1. Especially named parameters and auto defining properties in constructors.

Thread Thread
 
dyriavin profile image
Alexander Dyriavin

Strongly agree!

PHP8 game changer as for me.
Brings less boilerplate code, gives you 30% performance boost (thanks to jit )

Collapse
 
insidewhy profile image
insidewhy • Edited

Your ideas about "elegance" and "simple" are not given enough context to be descriptive. I can't even tell if you think you're being objective.

I dislike PHP because it's inconsistent and inherits baggage from objectively poor design decisions that were made in its past. I like many languages that are regarded as more complex than PHP and many that are regarded as less. I believe you'll find that this is the same for many others.

Thread Thread
 
dyriavin profile image
Alexander Dyriavin

Depends on the context and what problem has to be solved.

In every single language we can find inconsistency, mostly because:

  1. Langue built by people
  2. Langue used by people

Taking into account that people different, we cant find a consistent language.

What is important: I dont saying that PHP is perfect, i am saying that people talking "its dying", but its not the case. And the hate around it - as for me - not fair

Collapse
 
insidewhy profile image
insidewhy

What do you mean by "complete and powerful"?

PHP seems to have a much smaller domain, lower salaries and to be generally more loathed.

Even if it was objectively superior to JavaScript (which I strongly disagree with), learning it or continuing to use it is not pragmatic, few want to be paid less, have fewer career options or be looked down on by others, no matter how unfair that may be.

Collapse
 
pyrsmk profile image
Aurélien Delogu • Edited

I mean that the API is more complete, and that its syntax has more modern features (especially in OOP) than Javascript. I don't speak about other PHP native modules, or Node because both have not the same age nor the same purpose. But for example I always find annoying how poor the JS Array API is. And even if I don't like the mainly procedural API of PHP, it has more functions to manipulate arrays than JS.

Thread Thread
 
insidewhy profile image
insidewhy • Edited

I guess you're not too familiar with recent ES standards, but when it comes to OOP JavaScript and PHP are very close. JavaScript has private methods/functions now, but not protected. TypeScript has had this level of encapsulation for quite some time though.

I think in general it's not objectively correct to say that PHP has more "modern features" than JavaScript. One thing that really bothers me is how verbose functional programming can be in PHP and many would argue that functional approaches to coding are becoming more popular than OOP (does that mean "more modern"?)

By API I think you mean standard library, this isn't so much of a problem for me given how easily it is to fill these gaps with third party packages and once you throw tree-shaking into the mix there isn't even a runtime size or performance penalty for doing so.

Thread Thread
 
pyrsmk profile image
Aurélien Delogu • Edited

I'm aware of recent ES additions. Compared to PHP 8.1 there are many things where Javascript is clearly behind PHP. But, indeed, FP in PHP is quite a pain to use.

Yes I meant Standard Library, my bad. Indeed, we can fill the gaps with third party libraries, but it points out what the language lacks of. Anyway, PHP also miss many things and with my comments I just wanted to underline that : no, PHP is quite different from what people think of it. And : yes, Javascript is not especially superior. All depends on what we're talking about.

For example, Javascript is a clear winner when it comes to async task handling.

Edit: just to add that we should not forget that PHP has static type checking

Collapse
 
dyriavin profile image
Alexander Dyriavin

In general, from my experience, i would say that if you are familiar only 1 language, your salary will be lower. Business need problem-solving, and usually you need to solve problems using different technologies.
This is not applicable for JS, since there are a lot of different options to use.

Initially this article suppose to show, that PHP its just the same tool as any other Programming langue, its not meant to say - go learn it.

Collapse
 
pyrsmk profile image
Aurélien Delogu

I completely understand that. I don't even program in PHP anymore myself. Because of the syntax and the procedural API. To me Ruby and Crystal are way better than PHP because of this. In Ruby/Crystal, everything is concise and straightforward and it's a shame it does not have more traction. But eh, everything is about trends!

Thread Thread
 
dyriavin profile image
Alexander Dyriavin

As for me Ruby being underestimated also.

Collapse
 
alaindet profile image
Alain D'Ettorre

PHP is not dying, but it's massively shrinking. It survives today because of these 4 reasons and 4 reasons only for me:

  • WordPress is everywhere, good luck maintaining that code
  • Laravel
  • Cheap costs, deploys and developers
  • Huge amount of third-party libraries and code to maintain

However I'd never choose it for anything relevant these days because it falls short on things like serverless, WASM, compilation, anything outside web development and even testing and standard library are a bit loose. Sure it got better and will pay bills for another decade at least, I've used and appreciated the language, but it's not where the market is going.

JavaScript is much better in terms of integration and ecosystem despite not being as fast, Go is superior in anything except for adoption for now, I don't like Python but still it has very good traction, big third-party registry and does wonders on serverless as well as in any other field except for web development, then there are Java and C# which are both evolving, has massive enterprise support and will surely last longer because of that.

PHP is not dying, but I wouldn't bet on it

Collapse
 
twirp profile image
twirp

I don't think PHP is dying, but I do think some languages excel in use cases compared to others. I started with PHP4 and used it up until PHP7. My problems and scenarios grew to where other languages supported what I needed to do natively, while PHP felt like a hack or workaround.

PHP and its frameworks are constantly playing catchup. Native Call (FFI) was added in PHP 7.4, Fibers were adding in 8.1, in memory storage was added in PHP 7, threads in PHP cannot be used with a web server, there's no real good solution for web sockets. Most of the time PHP is associated with Shared Hosting, where you don't have the ability to perform complex tasks or bind to ports.

Laravel is a step in the right direction, but there's limitations in Shared Hosting environments where vanilla PHP excels.

Once you step away from Shared Hosting, the argument for PHP is harder to make. For developers who grew up with PHP's initial limitations, a new and improved PHP release isn't enough to convince people to switch back. Constantly playing catchup and knowing limitations are present provide enough reasons to stick to something else for most people.

At the end of the day, it's personal preference.

Collapse
 
dyriavin profile image
Alexander Dyriavin

Fully agreed, looking at the features and progress around PHP - i dont see its dying, i see how the language becomes better with each feature and release

Collapse
 
dyriavin profile image
Alexander Dyriavin

Valid point. But as for me there is still no universal language, which can provide you both with 0 complexity of maintenance.

Collapse
 
fjones profile image
FJones

For me it died around the same time, but for a different reason: PHP, around that time, started to move in a direction that doesn't really work for me. It has become a highly opinionated language that, in many ways, tries to emulate other highly opinionated languages.

It's not even just an additive "let's add features to enable more modern best practices" approach, but an active attempt at disabling old language features to prevent supposed missteps. That's not what PHP was about.

Thread Thread
 
pyrsmk profile image
Aurélien Delogu

It was about templating language? 😄

Collapse
 
jacekandrzejewski profile image
Jacek Andrzejewski

Nowadays you don't have to write it twice if you use Laravel with Livewire. Or in case of validation you can use Laravel-Data and generate Typescript definitions of objects. Both have their cons of course.

 
pyrsmk profile image
Aurélien Delogu

Didn't know Bun. This runtime is pretty cool!

Collapse
 
armanist84 profile image
Arman

So, it means the only option is Node. js over there for you?