Hacker News new | ask | show | jobs
by cheald 5190 days ago
> What would be fascinating would be an attempt to understand why PHP remains so dominant despite the well-known flaws.

I've actually put a fair amount of thought into this. I've arrived at the conclusion that it's because it ships with the Big Three parts of any web app in a single package: Request/response handler, scripting engine, and template engine. To the novice, there is no distance between the query string in the URL and the parameters available in $_GET and the ability to write those parameters back to the page via <?php echo ?>. They're all wrapped up in a handy mod_php binary that runs in Apache, and you probably don't even have to do any extra work to get it to run. It Just Works. This has nothing to do with PHP as a language, but it has everything to do with PHP as a web-oriented product. PHP isn't for systems administration, or generalized scripting, or embedding in your game to serve as its scripting engine. It assumes it's web-facing, and that removes a lot of the friction that otherwise trips people up.

What this means is that it's trivial to deploy full-blown applications like Wordpress, phpBB, Joomla, Drupal, and a host of others. They are literally as simple as "unzip this file and go to http://yoursite.com/package. That's huge! As a Ruby web developer, I'm envious of that. I wish I could give people a zip, say "drop this here and unpack it and you're up and running".

PHP is the lowest-user-overhead "make things happen on webpages" language in use right now. This comes with all kinds of downsides which many of us are familiar with here, but PHP's success has nothing to do with the language itself, and everything to do with how easy it is to deploy a full PHP stack itself, and then any PHP application on top of that.

1 comments

That's a really good analysis. I'm currently mostly using Python, but I've had a lot of PHP experience. Once everything is configured python is a dream, but if I just want to prototype a simple website, it just isn't worth it. Same for the average blog or small scale business site.

To me this signifies a significant hole in the market that competing products could fill. We've already seen that, to some degree, with platforms like AppEngine, but not so much with self-hosted solutions. Or do such things exist? If so, why are they not more prominent?

Another huge bonus for PHP is that a AMP stack is easy to run on Windows, Mac or Nix. The same cannot be said for Rails or Python.

Exactly. To get Python running, you need your webserver, some kind of fcgi/wsgi module or interface running in your webserver, specialized configuration for your app in your webserver, Python installed, some enumeration of your app's packages installed, and finally, your application running.

We laugh at PHP as a giant glob of senseless stdlib crap, but for its purpose as a web-facing product, it works. Users almost never have to worry about installing extra libraries or modules. mod_php means that you never worry about whether or not you have mod_proxy and some fcgi wrapper installed. You don't have to worry about process management.

This doesn't make PHP less of a disaster from a purist's standpoint, but I think it's exactly the things that make it a disaster (gigantic stdlib, no real package manager to speak of, single-threaded, designed to run in short-lived processes and then die off, etc) that make it widely accessible as it is.

I still think there are huge issues with PHP as a language, and I'm long past the point where I'd consider it an ideal candidate for web applications development (because I can deploy python and ruby apps with ease now!), but it has wildly succeeded at hiding all the underlying machinery from the user so that Joe Average can just start scripting his webpages.