DEV Community

Luna Miller
Luna Miller

Posted on

PHP, The Internet's Favorite Scapegoat

I’m not sure when it started, but more and more programmers are moving from PHP to Go, Java, and Python. Of course, there are also migrations between the latter three, but you rarely see anyone switching to PHP. This phenomenon got me thinking, and I realized that PHP is indeed the perfect scapegoat. Maybe it's because its logo is an elephant, making it inherently more capable of carrying burdens.

Image description

System Issues? Blame PHP

When systems constantly have issues online, PHP's fault. When a post-mortem is needed, and someone has to take the fall, it can't be because of our own incompetence, right? So, let's blame PHP. After all, it won't argue back. Blame PHP for being a dynamic language with loose restrictions, which often leaves unnoticed pitfalls. We definitely need to refactor.

If the same people who originally wrote the code are the ones refactoring, regardless of the language, the result will likely be the same. They’re just rewriting the old code in a new language without questioning if their initial design was flawed.

Some even write Go or Java code with a PHP mindset: initializing a bunch of things manually in the main method, defining a ton of map[string]interface{} in Go, or using multithreading to access class properties in Java without locking.

High IT Costs

When server costs remain high, that's PHP's fault for poor performance and single-threaded execution. Honestly, not many companies have massive traffic. Most don’t even get that many clicks in a day. If performance is an issue, it’s likely due to a bunch of slow queries running constantly. Switching to C++ or RUST won’t magically fix that.

Remember, PHP was the initial language used by Facebook for building dynamic website content and server-side functionality. I doubt many companies have more traffic than Facebook.

New New Teams

It’s also common for new leaders to clean house. Many people online ask why a company’s system uses three different programming languages. The usual answers revolve around each language being suited for different tasks, but the real reason is often that the company has changed CTOs multiple times, and each brought in their own preferred languages.

When a new technical director arrives, they often try to clear out the old team. During this time, PHP gets blamed for various issues, supposedly hindering future business development and IPO plans. This tactic is used regardless of the development language to justify removing dissenters.

When PHP is blamed and a switch to another language is proposed, some programmers might even cheer. Try switching Java to Go or vice versa; it’s the same story. Last year, our new CTO made us switch from Go to Java, and some colleagues vented on an anonymous forum, claiming it was a step backward.

In reality, if the new leader saw Java, they’d probably make you switch to Go. Overhauling the tech stack is just a way to clean house, keeping compliant team members while getting rid of those who don’t align with the new direction.

KPI and Promotion

Even without a new technical leader, in this KPI-driven, OKR-obsessed era, everyone has to find work to justify their existence. How else can you show that your team is working hard, staying late every day?

PHP becomes the perfect stepping stone. Managers can pitch to higher-ups that a legacy PHP system needs to be reworked with the latest fancy language, assigning the task to someone reliable. This way, even if a promotion isn’t guaranteed, high performance ratings are almost certain.

In conclusion, these are my thoughts and personal views on why PHP often ends up being the scapegoat. This analysis might not apply to truly tech-driven companies. People love comparing programming languages, but the best one is the one that suits your needs. Comparing languages is like ranking sports stars; it’s mostly subjective, but it generates interest and traffic, which in turn supports many people.


At last, I recommend a PHP development environment that I've been using — ServBay. It's an all-in-one development environment management tool that comes with multiple programming languages and database components, including PHP, Node.js, MariaDB (MySQL), and PostgreSQL. The most important feature of ServBay is its support for using non-existent domains (Domain) and suffixes (TLDs) in local development. It even creates free SSL certificates for these domains, allowing developers to work in an encrypted HTTPS environment (e.g., https://api.servbay). This not only enhances the security of the development process but also significantly saves on domain and SSL certificate investments.

Top comments (7)

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

When people shit on PHP they usually do so for really weird reasons. It shares many problems with other languages that don't get that treatment; look at ruby on rails: it runs a slow, interpreted language with dynamic typing.

My guess as to why ruby doesn't get as much hate is that it just has a different culture: When enough people run into a typing problem, someone will sooner or later build a convenient DSL to validate types at runtime.

PHP is just a poorly designed mess that started out as glorified string interpolation for html files and somehow ended up turning itself into a somewhat usable object-oriented language; but the legacy and the surface-level flaws just make it hard for anyone without a bias to look at it and pick it for an important project, which leaves it in the hands of those who learned how to build web applications from LAMP tutorials 20 years ago and now just use the tool that continues to work for them.

Collapse
 
istvanujjmeszaros profile image
István Ujj-Mészáros

PHP 8 is basically C# without generics. The ecosystem is very different, but I still find PHP to be more productive for web apps. It’s also safe, providing essentially the same type safety when used with a static analyzer. While it lacks runtime type safety, that’s not really required.

Compared to TypeScript, PHP (especially with Swoole) definitely beats it in both productivity and performance.

As for Ruby, it’s quite a unique language. While it’s one of the slowest languages and the architecture of Rails is flawed, the language itself is not bad at all. I like that everything is an object, and syntax like 3.days.ago is very easy to work with.

Collapse
 
ecrider profile image
Kuba Paczyński • Edited

Nowadays PHP is a beautiful beast - it's basically extendable, JIT compiled, efficiently garbage-collected... C. Almost every native function is not some abstraction glued on top of mountain of abstractions (hello Python), but is actually written and executed in C - an actual runtime that operates underneath. Almost all low-level functions are nothing but a thin layer of syntactic sugar spread over bare metal - if you stick to those it can compete with anything in raw speed execution performance.

Whatever it doesn't have you can add yourself - write your own little hyper-turbo-ultra performant custom modules in C to do all the heavy lifting you need - then plug them as extensions and build on top of it to enjoy comfort and convenience of high-level PHP, like a boss... It's good to live a little while everyone else is permanently stuck in abusive relationship with a compiler.

Collapse
 
istvanujjmeszaros profile image
István Ujj-Mészáros

"Write your own little hyper-turbo-ultra performant custom modules in C"

Or in Rust! PHP is designed to be a templating engine, which makes it extremely productive when working with web apps. The only bottleneck is the ecosystem. And I don't find the popular frameworks productive enough. But that is true for other languages as well. Almost every one of the popular frameworks are misusing the MVC pattern, making the apps much more complex than necessary.

Collapse
 
denys_bochko profile image
Denys Bochko

It could be that PHP is not a "pure" server-side language, even though that is where it runs.
It has its uses and if somebody has an issue with loosely typing of it, well, try an IDE. PHPstorm or VScode will help you with your typing problems.

I don't think any languages has issues, the problem is that people forget that each project should be considered separately and language figured out for it depending on the final goal.

it is the same in real life: if you want to pull 20-ton load, you are not going to use a sedan or even an SUV, you are going for a track.

Same thing in programming, for simple projects, use whatever you are most comfortable with, for others choose the tech that's more suitable for it.

PHP has disadvantages, but so do other languages. It's a niche language but it serves its purpose of being a good scripting language.

It's very simple: you don't like it, find something you like. Consider it slow or bad, find what you cosider good and enjoy it.

Collapse
 
valvonvorn profile image
val von vorn

I don't see anyone moving from PHP to Java in the era of PHP 8,
or is this a repost from ten years ago?
Do you have stats to hold up your premise?