10 ms·
The secret to PHP's success is simple. I've never seen anyone point it out. It just works. If you have a web server configured to run PHP, then it's ridiculou
by api 15y ago
The secret to PHP's success is simple. I've never seen anyone point it out.
It just works.
If you have a web server configured to run PHP, then it's ridiculously simple to get a page to execute. Just put a .php file on the site and it runs. Done.
You don't have to jigger a bunch of components, dink around with a bunch of Tomcat or Ruby on Rails or proxy or other annoying settings. Most other web execution environments have a bunch of Rube Goldberg machine components you have to plug together to get them to work. It also performs very well and supports a lot of things.
- emperorcezar 15y agoYes, it just works. That's also where there are thousands of poorly written sites out there that chug down sql injections like they were going out of style. PHP is a reasonable templating language. That's what it should be used for. If you use a framework, you're golden, but at that point you could be using any language.
- sbarre 15y agoIf [language of your choice] was as popular as PHP you can bet that there would be thousands of poorly written sites in that language out there too.
- TylerE 15y agoI sincerely doubt that. PHP has fundamental issues. It's like the people 10 years ago saying "if [other OS] was as popular as Windows XP, it'd be overrun with malware too". No. The issue wasn't Windows marketshare, it was the completely crap security.
- chunkybacon 15y agoThe issue was both Windows marketshare and crap security. If it wasn't easy to write malware for Windows not as many would write it. If there was no one to infect with the malware, also no one would write it.
- jrockway 15y agoIsn't not programming at all even easier? You don't have to get money, find a computer to buy, buy a computer, install an OS, buy an Internet connection, install a web browser, learn to browse the web, learn about how hosting works, find a host, get money to buy a hosting account, learn about apache, install apache, learn about php, install php, learn about text editors, install a text editor, learn php, write PHP, learn about scp, install scp, scp file to server. By the time you've become that proficient with all that stuff, apt-get install libcatalyst-perl on your desktop sounds about as easy as finding a host that supports PHP. It's not like PHP solves any of the real problems, like how to manage upstream changes, how to automate releases, how to rollback database schemas after a bad release, and so on. The reason why nobody ever talks about those things is because everyone handles them with downtime and swearing. That's not software engineering. That's fail.
- furyofantares 15y agoNot programming at all is easier, yes. Not programming is also much more popular than programming in PHP. Edit: To be a bit less snarky here, you are arguing that the sunk costs of learning to use a computer justify more effort spent in getting a web site running just because the effort already sunk dwarfs the additional effort required. But in fact not only is that cost sunk but once I've learned to use a computer my time and energy is suddenly more valuable.
- sbandyopadhyay 15y agoFalse dichotomy. You can do some things quickly in PHP (vs other languages), and some things in life and in programming need to be done quickly. There's a place for doing things fast, and a place for doing things right. You're wrong to assume everything requires the latter.
- justinjlynn 15y agoIf you don't have time to do things right, how are you ever going to find time to do them over and over again?
- 15y ago
- Lazare 15y agoTrue. A lot of webhosts are configured such that you can drop some PHP files into a directory via ftp, and it'll "just work". Which is nice. But... ...that's not really inherent in PHP. You can configure Python to be just as easy, and some webhosts do this. Node is pretty much always this easy. Django and Rails can also be this easy (if you've ever used Webfaction, you'll know what I'm talking about). And, on the flip side, if you want to install configure PHP yourself, it's actually not that easy. It's trivial to get a PHP page to execute given a web server configured to make it trivial (but, again, that's true for almost any language), but configuring the web server isn't trivial.
- maratd 15y ago> And, on the flip side, if you want to install configure PHP yourself, it's actually not that easy. http://www.lifelinux.com/how-to-install-nginx-and-php-fpm-on-centos-6-via-yum/ http://www.lifelinux.com/how-to-install-nginx-and-php-fpm-on... Looks pretty easy to me. Then again, I compile my own version of Apache with FastCGI and PHP-FPM all the time.
- tambourine_man 15y agoWas going to say the same, yum makes it very easy. What we need is a Douglas Crockford for PHP. A “PHP: the good parts” and a good PHPlint would do wonders to the language and community.
- sgerrand 15y agoAs previously discussed on HN, Robert Eisele's fork of PHP (at v5.3.6) which attempts to fix many of the issues. http://www.xarg.org/2011/06/php-hacking/ http://www.xarg.org/2011/06/php-hacking/
- Lazare 15y agoTrue, that's pretty easy. But it's also just as easy as getting most other language or frameworks up and running. And since the argument I was replying to was that PHP was good because those other languages are too hard to configure then, implicitly, PHP is too hard to configure - at least for the guy I was replying to. And if you're relying on your webhost having your language-of-choice already configured for you, well, you can find webhosts with most of the obvious choices already configured. So what does that leave? I would suggest that PHP does not, today, have any advantage over other competing languages and frameworks in the "it just works" sweepstakes.
- alanh 15y ago> I’ve never seen anyone point it out. Really? The easy of deploying a single-purpose script / hello world is always trotted out as the reason PHP ever became popular. Yes, even in yesterday’s big item “PHP: A Fractal of Bad Design.”
- MartinCron 15y agoI've seen people point it out before and I think it makes perfect sense for explaining its popularity. I also think it's a micro-optimization for the wrong thing. It's like buying a car based solely on how close the dealership is to your house. You only have to do the initial setup once (by definition) but you have to live with the consequences of your environment of choice every single day for the rest of the project. I'll go to a crappy coffee shop if it's the only one around, I'm willing to go very far out of my way to get to the car dealership that has the right thing for me.
- sbandyopadhyay 15y agoPeople trade up cars all the time -- when you can afford to, that is.
- MartinCron 15y agoUsing PHP just because it's easy install isn't like buying a cheap car because it's cheap, it's like buying a cheap car because it's just a little bit closer to walk to than another cheap car.
- sbandyopadhyay 15y agoTo the extent that learning languages takes time (it does) and to the extent that setting up an environment takes times (it does) and to the extent that time is money (it is), I'd say using PHP in lieu of a premium language is exactly like saving money on a car when you don't have a lot of [time/money]. But in the end, what's most important is that the car/language gets you from Point A to Point B.
- MartinCron 15y agoIt's only saving money when you don't count the ongoing opportunity cost of using inferior tools and technologies, but that's a false economy. It's a short-term savings in exchange for lots and lots of serious pain going forward.
- fleitz 15y agoPHP is just an example of worse is better (whose key is simplicity of implementation), because PHP is easy to get started with things get built in it. Then you have a lifetime of maintenance hacking around all the bad decisions at the start because of it. Comparing the rails app config system to PHP.INI, ini_set, .htaccess and the million other ways to configure PHP and considering the app config system to be a rube goldberg machine is really unjustified, the very configuration of PHP itself pretty much non-deterministic. http://www.jwz.org/doc/worse-is-better.html http://www.jwz.org/doc/worse-is-better.html
- josegonzalez 15y agoDon't use all those ways of configuring PHP. php.ini works just fine, and if you truly need a different configuration for a specific application, a bootstrap file will serve to override the php.ini where necessary. Done.
- derefr 15y agoTrue, I suppose: if PHP were invented today, I imagine the pitch would be something like "it's the Dropbox of web applications: you just put files in a directory and they run." (...on that note, I just realized how useful it would be if Dropbox's Public folder executed PHP.)
- aneth 15y agoLife is filled with simple, easy, cheap, popular paths that lead to ruin. PHPs initial simplicity does not make it a good choice. Looking for happiness? Heroine "just works". Hungry and poor? Eating McDonald's three meals a day is cheap and easy.
- kamaal 15y agoExactly that is why both Heroine and McDonald's sell. It might sound scary. But in reality 'merit' is not the only motivating factor for adoption of anything.
- sgerrand 15y agoA large number of people have previously pointed this out. You're selling the virtues of mod_php, rather than PHP itself. As other have pointed out in this thread, you can easily configure a web server to behave like that for files in other languages like Perl or Python.
- RandallBrown 15y agobut the difference is that you don't have to configure a web server to act like that for PHP, because (almost) all of them come that way.
- slurgfest 15y agoWhen there are so many cases where it fails, mysteriously and/or silently, you really cannot say it "just works".
- fffggg 15y agoThis is truer than you know, but for the wrong reasons. I worked tech support for a shell provider in the 90s and I helped a LOT of users work through the mechanics of setting up a cgi-bin. One of the most difficult concepts for users without a technical background was file permissions -- specifically the execute bit. I believe PHP's ease of use primarily stems from what most would consider a security vulnerability: mod_php instructs apache to execute code from php files without the execute bit set. This is inherently the same sort of issue behind email worms on Windows -- exec handlers which pass code to an interpreter without honoring the lack of execute permissions. It's a terrible idea, and also widely popular. I have personally seen users switch from Perl to PHP purely because they could not figure out how to set the execute bit in their Windows FTP program. The rest is inertia, as far as I'm concerned.