4 ms·
This conversation gets so vitriolic every year or so when it comes up. I'm temped to go argue in the threads, bust instead I'll just share my (recent) experienc
by eloisius 5y ago
This conversation gets so vitriolic every year or so when it comes up. I'm temped to go argue in the threads, bust instead I'll just share my (recent) experience with PHP in case anyone is actually on the fence rather than here to flame.
I started out doing PHP back in the everything-is-WordPress heyday. It was easy to SSH/FTP directly into sites and edit things live, and that was also a very normal thing to do. I got good at PHP and felt kind of defensive when people said how bad it sucked. Right tool for the job and all that. But, after some time doing it, I knew I wanted to break out of my PHP shell and learn another language. For some reason I felt like I could only pick one more language to learn, so I was hesitant to do so. I ended up going with Ruby. Only then did I understood what all the crap talk about PHP was about. It's probably both a language problem and an ecosystem problem. The ridiculous, complicated iteration over deeply-nested array-dictionary-combo data structures with various counters stuck in local variables here and there that I had previously considered normal vanished before Ruby's sleek Enumerable module. Of course you can code better PHP and avoid writing those kludges, but as a junior coder, that's the thing that stuck out to me when I switched from a PHP shop to a Ruby shop. Kludges and the worst inherited Frankenstein projects of my career. I swore I'd never work on PHP code again.
I spent several years doing Ruby, and along the way picked up several other languages and now can't fathom why I originally had such hesitation to pick one to learn. After gaining enough experience to be a senior engineer, a friend recruited me for a job doing PHP. This was at a big company with tens of thousands of enterprise customers, high-scale stuff. The money was good, and I had heard a lot about how PHP had cleaned up its act since the 4.x days. It's object oriented now and has a proper standard lib! I spent 3 years there, and I have to say the engineering talent there was good. Many ideas from other languages like Ruby's Enumerable had been replicated in our toolkit.
However, the vast majority of the code was still weird data structures that are unique to PHP development because of its lack's both real arrays and real dictionaries. PHP has indeed acquired standard lib, but many pieces of it still have a crap implementation. It's like they went out of their way to make lousy APIs for things like dates, times, and durations. In every other language I've used, you can easily compare time durations (is 1 hour longer than 1 minute?). PHP DateIntervals are not comparable. The API for creating a new DateTime object at a specific date is still to pass in a specially formatted string. Or, if you don't like that, you can create a DateTime for "now" and then mutate it to set the date. They may be adding language features to catch it up with other languages, but it seems like they're obstinately doing it in the most PHP-like way possible
Long-lived resources like database connections, Redis connections, etc. plagued us. We had a whole middleware in our stack dedicated to holding open proxy connections to things like MySQL. The thing that PHP enthusiasts say make it so attractive (edit, save, refresh) also bites you in the ass because PHP processes spin up and die with each request. There is no long-lived process holding onto those resources.
As of 7.3, It was still the same old PHP I knew back in 4.0. It's still crap and this time I swear I'll never work on PHP code again ;)