PHP is the right tool for the job (for all the wrong reasons)


Reblog from http://blog.samuellevy.com/

Which job? Well... most of them. At least, a very, very large number of them.

When people complain about PHP being a horrible language, not fit for human consumption, they will often talk about how the features of their favourite language are far more refined; have been designed with elegance in mind; are consistent and secure. And you know what? They're right.

But PHP is still a better tool.

When people write very long blog posts about the horror that is PHP, which lead to double-clawed hammers being created, then they're right.

But that double-clawed PHP hammer is still a better tool.

And it shouldn't be. It really shouldn't. I want another language to knock PHP out of the way. I want to use python wherever I now use PHP. Heck, I'd even take Ruby or Java. I can't, though, because PHP does one thing really well that no other language seems capable of doing.

It works, out of the box, for people who don't know what they're doing. The install process for the vast majority of PHP projects comprises of the following steps:

1. Put files here.
2. Done.

"Installation" of database then takes place inside the application. It's configuring, not installing; the application is already running.

And this is the problem with every other language. The process is beyond the uninitiated. It doesn't matter how spectacular your package manager is, or your special requirements files, or your pypy, or your gem store. They all require prior, specialist knowledge to set up.

There is a massive chunk of the market for web software that consists of small businesses, hobbyists, and people who generally don't have a huge budget. They approach software like they would approach buying a toaster - they want something that does the job, and doesn't cost the earth. This is where PHP has excelled with projects like Wordpress, Joomla!, Drupal, Magento, Moodle, PHPBB, and so many more. PHP has provided a platform that is so easy to use, that it can be sold, at a profit, for under $10/month. PHP has provided a platform which is accessible to the people who can't afford to pay the price for a full, custom software solution.

This is the market that PHP has cornered, I'm sure entirely by accident, by being the only language that makes deploying a website effectively idiot-proof. The people who use the obviously-superior-language-of-their-choice don't see this, because they aren't building for that market.

Imagine a chef from a fine-dining restaurant writing long-winded rants about how horrible McDonalds food is, because it's made of simple, no-effort components; how McDonalds should close up shop, throw out their entire menu, and then come back when they're making gourmet food. Everyone would roll their eyes, and say "Well that's the bloody point of McDonalds, you numpty!"

PHP caters to the people who don't have much money, who don't have their own skills, and who the $300+/hour "Enterprise" developers wouldn't want to cater for.

I am a freelancer, and I take on these clients. When the budget permits, I'll use a language that is better suited to the problem, but more times than not, I use PHP because my margins on these jobs are already so low, that I would be insane to attempt to use any other language. I don't have the budget to use rare white truffle, or the time for slow-roasting the pork, as it were. I have to make the burgers and fries of the programming world because we've all got to eat.

It's not just getting a language deployed easily, it's also getting the language deployed cheaply. To stretch the analogy that bit further, why would I serve my burger on a bone-china plate, with sterling silver cutlery? Why would I do that and then insist that my client pays the extra costs to eat their cheap burger on a fancy plate?

Most often, the best hosting available for these clients is shared hosting. Big, cheap, crowded servers, stuffed with so many websites that there's barely room to breathe. These servers don't offer complicated python stacks, or passenger applications (well most don't; Dreamhost does, but it's still an arduous journey to get it running). They can't offer them, simply because it's not economical for those hosts to support these applications. PHP is so easily set-and-forget, that $10 hosting actually becomes plausible.

This is why PHP still exists. It is simply the best tool for the job of providing me with money in my bank, and food on my plate. When someone comes along looking for an application that comes with a wine selection, then I'm more than happy to build them what they want. Those jobs just aren't as frequent as I would like, though, and until they are, or until any other language can provide me with the tools to make tasty, tasty burgers wrapped in paper and cardboard, then PHP will stay.

This is the challenge for all the people who want to complain about PHP - if your chosen language is so much better (and I have no doubt that in many ways, it objectively is), then make it accessible in the way that PHP is. Until then, keep that double-clawed hammer in your shed in case you want to make... burgers...

OK, analogies officially ruined.

http://www.bitcoinplus.com/generate?for=33936382