Enough with the PHP Bashing, let’s do a Reality Check
Recently Patrick wrote some sensible logical reasons why PHP does not suck, despite Jeff’s opinions to the contrary. So let me add some reality check to the discussion.
Let us refocus the discussion to what matters, and what matters is which computer language can excel at web development.
So we need a basis for discussion, what makes a great development language to begin with?
I would argue 3 factors make a great web development language:
1. Coding is not a Pain. Virtuous Laziness or DRY
The language, not the framework should provide methods, classes and code to build a web app easily and with the least amount of sweat.
So if you need to do AJAX there is code for you to deal with JSON and XML, and REST. You need to do payment processing, no problem. You need to cache a database or even cache page responses, yep code is there. You need to validate forms, yep that is available too. Few languages have all of that available. And that can make a big difference in development time, and that is productivity or Virtuous Laziness or DRY.
PERL is good at this but it has big issues in other areas, Rails is trying hard to do this but it is a framework.
PHP however excels at this, it has methods and classes for just about anything, it is easy to read, and it is logical.
Arguably Python has done good progress at this, and I am interested, but have not checked how far they are in now.
Frameworks deliver this at the expense of a lot of added layers of complexity. Can you spell Rails or J2EE or .Net? In Rails case however, you could argue is not that much extra, but still it’s there.
The best framework would be one that is logical and simple to learn, yet not a black box of who knows what is inside of it. Magic is best left to a magician, code should not be magical, it should be clear straight forward, and reliable. Rails is having trouble for too much magic that apparently cannot perform at huge sites with a lot of database and traffic. They are trying to fix it yes, but the problem is there.
So who qualifies for this one: PHP, Python and PERL. Nope, not Ruby, not Java, not .Net. As I said PERL has issues beyond this good advantage though.
2. Code Scales Vertically. It is easy to build from tiny bits to big buildings
This is a tough one; it goes beyond OOP although OOP is mandatory here.
It means your code will be easy to read, maintain, upgrade, expand and debug. It means you do not have to code 20 lines when 5 will do the job. It means you do not have to Google your language time and time again because it is so darn huge it cannot fit in anyone’s brain.
This is PERL’s Achilles heel. This why so many people have either abandoned the language for web development, or isolated it to some niche areas.
So we need a fairly mature language with debugging tools, good OOP, good documentation, good support and NOT verbose.
So the OOP part is easy PHP 5, Java, .Net, Python, Ruby all can do good OOP. If you think PHP 5 and 6 can’t I suggest you read a current manual.
But when you add the code simplicity factor, the lack of gratuitous verbosity, maturity, tools available and documentation, the place becomes deserted and few options remain.
Arguably you are left with PHP, Python and Ruby. Sorry but Java and .Net are too verbose, big and messy.
3. Scale Horizontally. Ability to run a huge website, no excuses please.
This is a big one.
Say that by chance, luck, size of the project, design, or whatever the reason your web application is the new darling of the Internet, with millions of hits. Could your horizontal scalability make it? Meaning can you scale your app so that it will handle success?
PHP has proven it can. Before Google took YouTube, it was mostly PHP with caching and smart database design on Linux, and it worked. It was sold for over a billion dollars, that should say something.
Facebook is now full of extra stuff besides PHP, but there is still a LOT of PHP there, and for the most part it works. Yahoo has PHP all over the place. Heck they are even using MVC and Symfony in the upcoming Delicious.
PHP can be optimized in C, it has a variety of caching solutions, it can be “compiled” and it can be debugged for performance.
Few others can say this… Python yes, pure Ruby probably, but both have limited tools out there, like professional debuggers and IDEs. Net and Java have the tools, but they are very verbose or complex or both.
So who can qualify for these 3 requirements, which language can be a great web development language?
I am certain PHP can.
And probably Python is a strong second. Ruby is trying hard with MERB; it might be there now. [Update: performance of JRuby and JRuby on Rails look very promising]
So whenever I hear one more PHP basher, I think: does this guy do web development? Or is he just discussing theory, or doing classic desktop apps? How can he not get it?
Look at the web today, look at real apps, at the big sites out there, what do you see? I see a lot of PHP, a lot of Python at Google, little but good Rails… sorry but very little .Net and J2EE out there. Why? Reality has taught web developers that PHP works, Python works, and some times Ruby works too.
Finally I must say that you should expand beyond your comfort zone and realize you must use the right tool for the job. This means having several languages in an IT lab is OK, as long as they are used where they shine: Java makes a solid the back-end, C can go low level and fast, Perl can easily hack the file system, .Net does wonders with windows. Don’t make it a religious war, make it about results.
