Saturday, December 4, 2021

defending php with the importance of context

I found a pretty good article discussing Why developers hate PHP. (Spoiler: it starts seeming to support the negative vibe, but then comes around to a more balanced position.)

You can tell I'm getting defensive about PHP when I link to Taking PHP Seriously, but it has been interesting exploring why it is sometimes hated with such vehemence. (That last article, it reminds me of the old old rant Object Oriented Programming Oversold! , except OOPO is punching up and the anti-PHP stuff is generally punching down.)

(That said... some of PHP's stickiness has to do with WordPress, and... I do not enjoy configuring or making up custom widgets for WordPress...)

As I ponder on it... yeah, there's much I can't disagree with - the API is a mess, and I am completely reliant on Google to relookup every function - some of that is my age/learning style and some of that is the style of the times, but still. (On the other hand, so many of the edge-case-y "how can you live like this" parallel critique of javascript, like when equality and null/undefined and implied type conversion get weird... and this drives some people nuts but I am unconvinced it causes that many problems in real environments.)

But I still think that developers who hate it SO MUCH... well, it reminds me of my friend Jon, who recently dabbled with a toy project to learn TypeScript a bit. He didn't like TypeScript, and when I looked at his code, I saw he was trying to bring over the same OO principles from his other work, and I agreed that was a terrible fit for the language. (I didn't try to convince him that OO was indeed oversold, but as I think about it... the idea of bundling data and operations kind of goes against the grain of functional programming, and its love of immutability?) Basically, it's the wrong tool for the job, or at least for the mindset.

Anyway. My current lens for looking at the world, especially the world of tech, is "Holism vs Reductionism". Reductionism as a term has a bit of a stigma, but it's absolutely a critical half of programming- taking a complex problem and breaking it into steps is the bread and butter of programming, and functional programming and avoiding side effects - isolating - are all critical bits. 

But Holism is important too, because it is understanding how all the parts come together. ("Bugs are an emergent property" is my current thinking, so if you're not looking at things how and where they connect, you do not understand the system.) And I think a lot of the classic developer type discounts the need for the holistic and context sensitive understanding.

So, it's all about context. And I think that applies to PHP - deployment is acknowledged as its sweet spot. And I wouldn't want to do big engineering with it, but man... keeping simple things simple is so critical, that it makes up for the sometimes glaring flaws in the language. That wonky API... I mean it sometimes seems aggressively and gratuitously inconsistent, but having so many functions handy compares favorably to, say, bad old days of Perl (where everything was a install from CPAN) or even modern React (where create-react-app pulls down gigs and gigs of libraries, just in case, each having its own set of documentation if it IS the part of the kitchen sink you've learned about and want to use.)

Of course it's a mix of language and API/toolkit. I mean, it's weird that PHP is a language per se... that's where its immaturity most shines through. 

I mean, maybe if Rust or some other language was quite as easy to deploy, and had outputting DOM bits so baked into it, it would be worth checking out, but I'm not sure if such a thing exists, or would have enough of an audience to be worth learning (and figuring out how to install on my cheap rented webspace, which honestly is a big part of my loyalty to PHP...)

Heh, besides refactoring my blog's backend editor from - gak- ancient Perl CGI to PHP, the other thing that got me going here was working up a quick and easy page to display a pile of memes I had collected: kirk.is/memes/ - I feel like this one would might have been useful a full times as i read through the PHP hate pages...



No comments:

Post a Comment