Trevor Burnham

Sure, it works in practice…

PHP Must Die

January 2nd, 2010

PHP > RubyI’ve been working on a mockup for The­o­ryville, and I wanted to throw together a server-​​side script to respond to some simple AJAX requests. My first thought was to do it in PHP, but then I remem­bered that PHP is the least elegant language in the world. So, I figured, I’ll do it in Ruby! I wrote what I needed, uploaded it to the Apache server, and I was done—except for the minor detail that Apache wasn’t running the code.

I figured that fixing the problem would be a simple matter of adding an AddHandler line to the Apache con­fig­u­ra­tion. At worst, installing some sort of mod_​ruby. No such luck. Turns out mod_​ruby was aban­doned many moons ago. The reason? Effi­ciency. Starting and shutting down an appli­ca­tion every time someone makes a query is a stupid, grossly inef­fi­cient way of doing things. But guess what? For many appli­ca­tions, folks don’t give a flying fork how many processes they spawn. They only care about being able to upload some­thing to their existing web space and have it just work.

Example: You could write a fan­tas­tic new blogging platform in Ruby, but would it have Wordpress’s Famous 5-​​Minute Install? No shell access required! Just upload it, go to the instantly avail­able web inter­face, and tell it how to find your database. You know, the one you set up using php­MyAd­min?

Look, the Ruby com­mu­nity is rightly proud of Rails. I’m not saying that large or high-​​traffic web appli­ca­tions should run on PHP (though Wikipedia and Facebook somehow manage). But if you’re a Ruby­van­ge­list, you need to fight on every front you can—including the just-​​upload-​​it-​​to-​​Apache front. It’s great that you’ve made installing and running a spe­cial­ized web server take just 4 shell commands. But for most folks, that’s 4 too many.

Rubyists, I urge you: you need to bring back mod_​ruby, for all our sakes. Anything PHP can do, Ruby can do better.

[Addendum: It’s worth men­tion­ing that there is a solid mod_​python, and it behooves all Apache admin­is­tra­tors to install it. Also, I was able to rescue my Ruby script the old-​​school way: CGI. I added #!/usr/bin/ruby as the first line of the file and changed the exten­sion to .cgi. I feel slightly dirty, but it works.]

[Update 1/​9/​10: While I thought the title was original (at least, to the extent that any hyper­bolic title is), it turns out there was an excel­lent post also called PHP Must Die back in the dark days of 2004 about how Python and even *shudder* Perl are better lan­guages than PHP. I took this fact as a given for this post. Via Hacker News.]

Tags:   No Comments

0 responses so far ↓

Comments are closed.