DEV Community

Cover image for Why developers hate PHP
Mehdi Zed
Mehdi Zed

Posted on • Originally published at jesuisundev.com

Why developers hate PHP

PHP is the most widely used language in the world for websites. It is also the most hated. And it's pure hate. But why do so many developers hate it so much? Today we're going to the origin of the hate, let's see if it's really justified.

Don't touch my PHP

If I'm saying that PHP is hated by the whole world, it's not my personal opinion. In the latest stack overflow survey, developers from all over the world put PHP in the top 5 most dreaded languages. The latest Hired survey puts it squarely in the top 2 most hated. There's a lot more and I'm not even talking about what's going on Reddit. If you're a PHP developer since 20 years who came here on a crusade to crucify me on the altar of Symfony, please relax. We're here to talk, put the gun down. Well now on the contrary if you hate PHP with passion : take some pop-corns and sit down comfortably.

Once upon a time I was doing some Symfony2 myself. And I liked the whole Symfony thing, frankly, it's not bad. I told this to a developer I met at a devops meetup. He was shocked, he was about to vomit, he looked at me like I just murdered a newborn baby. From now on I'm going to call him James to make it easier. So I immediately asked James a question: why so much hatred?

PHP trouble past

To understand what's coming next, you need context. In order to do that, let's make a little rewind. It's 1994 and Rasmus Lerdorf is quickly coding a C tool suite. This suite of tools is used to manage his personal website. Rasmus is doing it just for his own need at the time. He doesn't want to turn it into a programming language. Nothing in this tool suite is designed to become one. A year later Rasmus released this open source toolkit called then: PHP/FI. And it looked like this.

<!--include /text/header.html-->

<!--getenv HTTP\_USER\_AGENT-->
<!--ifsubstr $exec\_result Mozilla-->
  Hey, you are using Netscape!<p>
<!--endif-->

<!--sql database select \* from table where user='$username'-->
<!--ifless $numentries 1-->
  Sorry, that record does not exist<p>
<!--endif exit-->
  Welcome <!--$user-->!<p>
  You have <!--$index:0--> credits left in your account.<p>

<!--include /text/footer.html-->
Enter fullscreen mode Exit fullscreen mode

We're far from what you're using today in your huge PHP7 framework, aren't we? Yet it all comes from there. For the rest of the story : the code is taken over by a dev team and PHP/FI2 is released in 1997. In 1998 a part is rewritten and PHP3 is released. In 1999 the core of PHP is totally rewritten to produce Zend. PHP4 follows the next year and PHP5 is released in 2004 with Zend2. PHP6 got canceled because the development has turned into hell on earth. Finally, through yet another major rewrite of the language: PHP7 is released in 2015. I remember at the time I was very excited. But originally, Rasmus was just coding his own thing . In 2003 he did an interview and told some incredible things.

"I really don't like programming. I built this tool to program less so that I could simply reuse code … I don't know how to stop it, there was never any intention to write a programming language […]. I don't know how to write a programming language at all, I just kept adding the next logical step."

Inconsistency and poor design

Back in 2019 with our friend James from the meetup. He immediately started talking to me about the "disgusting" syntax of PHP. How the language is not typed. How the language is mostly unpredictable. Whether it's on the use of operators or the incredible inconsistencies in function naming. I'll spare you the list of technical problems because otherwise this article will take you all day to read.

If you really want to know everything I found you the most pissed off person in the world against PHP. No, actually I think the person who hates PHP the most is actually him. All those posts validate what James was telling me. Developers hate PHP because it's a technically inconsistent language with a bad design. When you compare it to other languages the contrast is obvious. If after reading these two articles you can't admit that PHP have some problems it's because it became your religion. And I stopped trying to convince fanatics.

Using PHP it's very easy to produce bad code. Other languages have many more restrictions. We also see a lot of security problems with PHP. And the problem is the same here. It's very easy to make bad and insecure code with PHP. But PHP is not a security hole or doomed to ugly code if you code properly. Developers hate PHP because you are more likely to get errors with a language that allows so much freedom.

Victim of its success

There is another important factor in this ambient hatred. Developers hate PHP because it is used everywhere. This blog runs on PHP7. Like most of the web I just need to host a dynamic page which is then cached. PHP does the job. Yes the language itself is not the best. Yes i could use a super duper stack. But who cares ? It meets my needs in a fast and accessible way. It's also for this reason that 80% of the web runs in PHP.

When I explained the same thing to James he started to go crazy. Like you and me, James have friends and family. These people frequently ask him for help with their professional and personal websites. Guess what language always comes up on these people's websites? So James finds himself having to change things in PHP often. And he gets incredible headache from it.

With the advent of WordPress, which literally dominates the Internet, James will play with PHP for a long time. By the way, I'm talking to you as if this language could only handle a blog like mine but that's obviously not the case. Facebook, Wikipedia, Yahoo, Flickr, Tumblr all these sites run in PHP and welcome millions of users every month without flinching. PHP does this very well and has been doing it for a long time.

The future is now old man

You've been hearing for 10 years that PHP is going to die. Yet he's still here. Despite time and the latest hypothetical technology, it's not moving. Developers hate PHP because it is the opposite of hype driven development. In a profession where everyone invests quickly on the latest stuff, PHP is an old man who doesn't want to sell his land. An old man who continues to dance insolently.

My discussion with James continues normally and all of a sudden he tells me something completely shocking. "On top of that PHP is by far the slowest language you can find for web". When he said that I understood that James didn't read anything on PHP since a long time.

PHP evolves, not its reputation

In the minds of many developers, PHP has remained in version 4. When the language was unstable, with disastrous performance and non-existent OOP. Developers hate PHP because they believe the language has been stagnating for 20 years. When you know PHP today you know that it's far from PHP4.

PHP7 is faster than Python and Ruby. The language can be strongly typed if you wish. Tooling is also evolving with static parsers that have appeared in recent years. Frameworks like Symfony or Zend force good practices. A new version is released every year with a very precise agenda. Moreover PHP7.4 is here with even more performance. Once again I won't list everything that is happening in modern PHP for the sake of length. If you want to know everything I invite you to read this article. It's time to change your vision on this language that has nothing to do with what it used to be.

Developers hate PHP because it's cool to hate PHP. This language continues to have a really bad reputation because of it. And yes, there is a strong legacy and a lot of problems. But there is a lot of good stuff too for most of the websites.

Epilogue

Most developers who hate PHP hate it out of elitism or ignorance. Either way it's dumb. You have to choose a technology based on what you need. PHP is highly useful and powerful in many scenarios. And taking it out of the equation just because of its reputation is not a good idea.

Latest comments (50)

Collapse
 
qaniel profile image
qaniel

its simple, cuz most devs have never touched JS... thats why php gets all the hate

Collapse
 
mikequade profile image
Mike Quade

Thanks for the article! After putting my gun down, I really enjoyed reading it.

My point is that PHP is old but I see it as an advantage. Older languages are not changing their language features all the time. The documentation is good, examples are available everywhere and it has a huge community to ask if you are stuck.

There are also lots of articles and best practices available regarding security. Or about how to write good code which imho relies on the dev's skills, effort and responsibility (maybe even a little bit of empathy) and not on the language itself.

With newer languages, I've already spent hours on finding code examples that actually work because half of stack overflow post examples are already deprecated or even the official doc might be deprecated.

That beats the bad code argument for me because newer languages might be safer and more restricted, but if there is no information or actual doc available about how it is supposed to be used, you'll end up hacking your code together again without really knowing what you are doing.

It might not be that easy as in PHP, but it can still cause a lot of trouble later and security leaks.

Collapse
 
andrewbaisden profile image
Andrew Baisden

When people think of PHP they immediately have thoughts about WordPress and it triggers bad memories that they might have had in the past with that experience.

Collapse
 
vikkio88 profile image
Vincenzo

thanks for this, as a guy who now works mostly on node/typescript, I miss a nicely written php codebase.

Collapse
 
kurisutofu profile image
kurisutofu

I admit I have a bad impression of PHP but that's because the last time I really used it, it was PHP4 ... I think my reluctance to touch it again is not really based on thinking it stagnated like said in the article but more because I found it so bad at the time that I think it's like PTSD ... just thinking of using it, I'm sweating, lol.
I'm pretty sure I will try it again someday but there are so many languages and technologies to try in programming that now, finding free time is the issue ...

Collapse
 
btlm profile image
btlm

PHP is very easy to learn and almost like "plug&play" - write a script, upload it to a shared FTP server and it works. Due that there are many wannabe developers who claim they are PHP developers because they wrote few webpages or even single scripts.

At my former workplace, we had many applicants who couldn't even connect with the database (but they judged their PHP knowledge as 4/5 or 5/5 in the CV).

I like PHP as it was my first language learned and I've been using it for long years and I don't understand the hate, excluding a reason given above. But it is a problem with people, not the language itself.

 
andreidascalu profile image
Andrei Dascalu • Edited

Sure, so the conclusion is that php is OK when not using kubernetes and when that's the only thing developers know.

Which is exactly the reaction I get from pure php developers. Yeah, kubernetes is difficult when trying do to anything with php because it is difficult (and in efficient) to do php under kubernetes (again, unless using roadrunner).

You don't need kubernetes, sure. Unless you need a way to autoscale quickly on demand, since it's faster to scale containers than vms (as you would in EBS). Which is something everyone ends up needing for any scale APIs, which is why I end up migrating php to golang as a full job :)

 
andreidascalu profile image
Andrei Dascalu

It is a factor when deploying orchestrated containers. In k8s for example, it's terribly in efficient to have nginx + php as separate containers with access to the same files. The request path goes like: external load balancer -> ingress controller -> local nginx -> fpm. There's an extra webserver in front which none of the other platforms need which only adds to latency.
The result is that on k8s, node + a fast router like fastify is roughly 3x times faster than your basic php rest api with Symfony. Although, if you switch to php + roadrunner in the same containerized context, php and roadrunner is roughly 2x faster.

Collapse
 
ihorvorotnov profile image
Ihor Vorotnov

Haters: PHP is BAD, PHP is DEAD!
PHP Developers:

Money

Collapse
 
bartosz profile image
Bartosz Wójcik

PHP is awesome, it's highly productive and with modern frameworks like Yii2 and Laravel you can build miracles within days. Plenty of packages, great documentation, tons of examples and a community that will help.

 
andreidascalu profile image
Andrei Dascalu

It's capable, I didn't say it's not. But assuming you have a team that also works with, say, elixir (or rust, go, node) - what would be the characteristic of the language that makes it more suitable?

It has detrimental stuff: its internal webserver is too poor for production and needs an external one, so container deployment with orchestration becomes painful. You can choose a high concurrency platform like Roadrunner, but only if you make your application fully PSR compatible and I still run into devs that haven't heard of PSR. This also disqualifies Laravel (poor compatibility with RR and poor performance) as well as Lumen (no idea what's the connection to Laravel since the core is not compatible)

Collapse
 
realtoughcandy profile image
RealToughCandy.io

PHP definitely leaves people... opinionated. Good read, fun memes.

Collapse
 
m4rcoperuano profile image
Marco Ledesma

Love your post. My experiences with many languages made me realize that it’s not necessarily the language that I dislike, it’s the context that it’s in. For example, I dislike PHP when it’s in Wordpress, but love it when I’m in Laravel.

I dislike c# when it’s in old MVC Microsoft frameworks, or even webforms (ew). But love it when it’s in dot net core.

I wonder if this is what most developers mean when they say they hate X language. Is it really the language? Or the context that you’re developing with the language? Maybe it’s a little of both. Idk. My 2 cents :)

Collapse
 
mukhammadsobirov profile image
Mukhammad Sobirov

I can't understand why would someone "love" or "hate" certain programming languages.
They're just tools that can be used to achieve certain goals.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.