DEV Community

Discussion on: Why bashing PHP makes you look stupid

Collapse
 
danjfletcher profile image
Dan Fletcher

There's a lot of misunderstanding around what PHP even is and what it's capable of. I agree that bashing it is uncalled for. I write a lot of PHP and have built a ton of applications with it that did and are still doing very well.

People should at least be informed before hating on it.

But that doesn't mean it doesn't have shortcomings.

For some people, the fact that PHP isn't a threaded language and likely never will be is a big deal breaker.

The way PHP applications spawn new processes with each request life cycle gives it a pretty significant hit against requests/second when benchmarked with other languages.

The fact that the same line of code can do more than one thing depending on the php.ini settings is pretty crazy to people coming from other languages. It's annoying at best. It's catastrophic at worst.

Or the fact that shallow comparison is rendered useless due to it's arcane inconsistencies and completely unpredictable behaviour. So why even have it?

It's type system is incomplete. Good luck auto-generating Swagger docs ever (and I don't mean hand writing annotations i.e docblocks).

Also, more of an ecosystem issue than a language issue but the fact that Type-Hints will coerce primitive arguments unless a script is in "strict mode" really sucks (in my opinion). For people coming from strongly typed languages especially, this is vomit inducing. But AFIK even loosely typed languages that support type annotations won't coerce types on you if you use annotations. Tooling could automate setting strict mode either through linting or a transpilation step but things like Hack never really went anywhere and most PHP devs don't bother with "strict".

Also, the most popular PHP framework is basically impossible to run in "strict mode" anyway so if you want true static analysis and type checking you have to use less popular choices (not the end of the world but still).

Until very recently error handling has been a mess. The fact that not all errors can be caught in a try..catch is asinine. I guess this is finally fixed in version 8 though? But how many people are even using 8 yet?

Language extensions are interesting but overall a PITA to work with and really just makes PHP impossible to use without VM's or Containers.

The core is complicated and maintained by volunteers with no backing from any major company. This could seem as a plus too but overall it means PHP is in kind of a tough spot. It's extremely difficult to contribute to, and few people really understand it. AFIK there's been a scent of burn out from some of the core contributors which is totally understandable but a little scary.

Another issue I see, although nit picky, is that for a new comer who is already an experienced programmer in another language it's probably pretty confusing. PHP doesn't look very "OOP" without 3rd party tooling. Autoloading is essentially like "linking" I guess? Only it's not handled by the language itself? Kinda weird. Plus installing and configuring PHP is quite the hurdle compared to other languages.

Collapse
 
danjfletcher profile image
Dan Fletcher

That said, I still have a distaste for the discouraging of new developers from learning PHP. That kinda seems like the trend for educational content now days. There's this weird lie (or denial?) that gets thrown around to aspiring devs that "PHP is a dead language".