Choosing PHP in 2022 and beyond
It&#x27;s impossible for me to take anyone seriously if they suggest picking PHP for any new project or deployment. Yes, there are existing high-quality services and libraries written in PHP and some of them have amazing communities, but that&#x27;s true for any programming language, and many of those other programming languages aren&#x27;t PHP. I recognize that people have extensive investments in PHP, and I won&#x27;t tell them that they have to throw that away, but don&#x27;t try to drag newbies into the muck, please.<p>PHP is a fundamentally broken design for a scripting language and the decades of heroic work from its maintainers cannot change that the basic underlying design was bad from the start. You can only fix so much without just devising a new language from scratch and somehow getting people to migrate, and at that point, they could just migrate to a language that doesn&#x27;t have all the baggage and a bunch of old (now inaccurate?) documentation and old broken code floating around.<p>At one of my first paid engineering gigs we ran a social game for 10m+ users where all of our online services were backed by PHP - live chat and state updates for the game&#x27;s native PC client went over http and were stored in memcached&#x2F;sql, we did transaction processing for user-to-user cosmetics sales, we had forums and custom user home pages, etc. Underneath all of that we had to build some complex systems so we had weird things implemented in PHP like distributed locks for cross-server concurrency (yes, really). We were able to get a lot done in PHP, which I guess is to its credit!<p>On the other hand, PHP was a constant nightmare. Every single line of PHP we deployed was a liability and a lot of it was stuff we didn&#x27;t have much visibility into. Once some random popular package we used for our forums - the coppermine photo gallery i think? or maybe phpbb itself? - was used by an attacker to jump in and exploit vulnerabilities in OTHER popular php packages we were using like osCommerce and clear all our payment processing configuration, making everything free without registering in the logs. I spent probably upwards of a dozen hours that friday night and early morning reading over every line of those packages with some colleagues to try and figure out WTF was happening, and it was SO difficult to do that audit because every single line of PHP was potentially hiding an assassin that wanted to stab you in the neck. To be able to ship and maintain our software at all we had to write an <i>incredibly</i> extensive set of automated unit and functional and integration tests, we required regression tests for every single fix and multiple tests for every new change because without that kind of rigor it was impossible to run a real service using PHP. Naturally we had to build most of the automated testing infra ourselves because the state of the art PHP testing frameworks were bad.<p>Later on we had another fun bug where the PHP unserialize() function was deserializing 4.0 into 12.0 (yes, really... though it may have been a different constant). I spent hours w&#x2F;a colleague reading over PHP&#x27;s C implementation trying to puzzle out how this could happen and in the end the conclusion we came to was that a .dll our payment provider required us to run in the PHP server was changing the floating point rounding flags for the thread, and not only did PHP not control its own rounding flags but it was extremely vulnerable to having them changed. Frustrating. (This is of course something that could happen with any language, but the low quality of PHP&#x27;s underlying implementation made it more impactful)<p>Also... WordPress. When&#x27;s the last time someone ran a wordpress install without it getting hacked? I don&#x27;t think I know anyone who&#x27;s successfully kept one up without getting owned. I lost at least one website because the shared hosting instance kept getting hacked via other people&#x27;s wordpress installs until the server&#x27;s owner gave up and took it down.<p>Over time PHP certainly has improved but I&#x27;ve used dozens of horrible languages and I think I would pick almost any of them over PHP if only because every time someone I know has used it they&#x27;ve ended up paying for it later. I would sooner write tens or hundreds of thousands of lines of VB6 or Perl or AS3+Flex than have to write and deploy a thousand lines of PHP because I just <i>know</i> the PHP would end up being a liability somehow.<p>If I could wave a magic wand and disappear one piece of software from history, it would be Bitcoin, but if I had two choices the second one would be PHP. Of course, this would probably be a setback for the progress of technology somehow since PHP empowered a lot of newbies and amateurs to ship working software, but we need only look at the long trail of mayhem and sorrow to see the cost they paid for shipping it using PHP.