I’ve just got back from @media2008. I’ve written up the conference over on the Sitepoint blogs – day one and day two – so I’ll not reiterate any of that here, however I didn’t want to turn those posts into a grumble so I’m back on home territory, where grumbling is almost obligatory.
Once again I sat through a Ruby on Rails demo which started with the presenter showing a slide of a PHP loop, throwing up his hands in mock horror and telling us how utterly horrible this is in comparison to the beauty of Ruby. The attitude seems to border on pity for or amusement at us poor PHP developers who obviously are too stupid to know better. This is usually backed up by an example of some crufty looking procedural PHP mixed up with HTML.
I don’t know about anyone else, but I don’t write crufty procedural PHP mixed up with HTML. The PHP that tends to be demonstrated in these examples doesn’t look anything like the PHP that I write on a daily basis, because these examples don’t compare like with like. A better comparison would be between a Ruby on Rails application and PHP using a framework such as CakePHP. And yes, it is possible to write horrible PHP, but that doesn’t mean that everyone does.
I’ve been a back-end developer for a long time, I’ve developed using Perl, Classic ASP, Java and PHP as well as playing with most other things at one time or another, and poking fun or rubbishing other languages has always been part of the landscape. It’s just the same thing as Mac devotees expressing mock pity for Windows users. However the problem with someone standing up at a conference and poking fun at PHP is that not everyone sat in the audience has 10 years of development experience in order to see through the enthusiasm of the recent convert to make an objective decision on what is right in any particular situation.
I like building web applications, and at this moment I choose to do so using PHP. I don’t want this to turn into a PHP apologetics post so for now I’ll just say that I believe that PHP is the best choice for the clients that we build applications for and the type of applications we are launching. However I do feel that PHP seems to have something of an image problem at the conferences I attend and generally on the web with the articles that are being written. The Rails community is nothing if not enthusiastic and also has the benefit of everyone being on the same page with Rails. If you use Ruby on Rails you do things in a certain way, because you are using a framework that helps you do that. This is a good thing, particularly for novice developers as they are being taught a solid way of working from the outset.
So does PHP have an image problem? There are a lot of people doing great things with PHP and a lot of huge sites relying on it, but had I not known better I would have thought it was a dying language over the last few days. Should those of us who are developing web applications in PHP be talking about it a bit more? Should we be presenting and writing about how we built our applications with non-crufty PHP, whether using our own frameworks or existing ones? Should we be selling the benefits of our chosen language so that people can make a more informed choice? I’d love to see a high profile PHP site that clearly explains the benefits in the way that rubyonrails.org does for Rails. The PHP.net homepage is great for developers but doesn’t do much to sell the language to anyone interested. Comparing PHP to Ruby on Rails isn’t comparing like with like, but as someone who uses and likes PHP as a tool to successfully build web applications, I’d love to see the good stuff being sold as effectively as the Rails community are doing for their tool.
7 Comments
It’s a problem of perception, so I suppose that makes it an image problem.
That slide annoyed me, too. I decided that we had been trolled. I am sure that if anyone had complained of its unfairness he’d have countered with something edgy about PHP’s inherent suck and lack of true OO purity.
Python and Ruby will always win purity battles with PHP, but those battles won’t do anything constructive for either party. Maybe the speaker realised this and picked a slide that was unfair and ridiculous to drive home the point that he’s really about solving problems quickly and transparently with something that works and the patterns used by Rails can help a lot with that.
PHP’s homepage isn’t limited to lacking pointers to clever time-saving frameworks. It lacks pointers to any sort of best practice, which is a bigger problem. It’s own manual doesn’t even hint at it, in fact the online manual can’t even decide if PHP is OO, with respect to its examples.
Again, I think this is deliberate. PHP is a very broad church, there are still plenty of PHP developers who won’t use OO, plenty who scatter mysql_query() into some HTML and PHP works for them because it works for their boss. Those people do not want to be reading about exception handlers or extending classes because they know PHP is already meeting their needs. The sad part is that these people are the ones who go all starry-eyed when they see Rails “not repeating itself” and they probably blame PHP for being PHP when they were the problem all along.
Like Rachel, I was taken back by the Ruby example. Mainly because the example given was using a for loop rather than foreach loop, which would have done away with some of the complexity demonstrated!
I agree with both Rachel and Philip here. It is a perception problem. As a PHP developer myself, I started to look around at other languages about a year ago. One to broaden horizons and two, people where asking for RoR a lot.
Ruby does have some sytax advantages over PHP, as everything is an object. However since PHP5, everything I do as OO in PHP feels cleaner and closer to the RoR examples always given. Now PHP has most of the tools required to exist in an OO world. PHP6 will add the rest it seems.
I personally think that frameworks like RoR and Django are just enjoying a lot of buzz because they’re new and some-how got that awful ‘Web 2.0’ label associated with them. I have had clients asking for a site in RoR and when asking them why they simply say “because it’s new and web 2.0” – yuk! If the clients are asking for RoR without knowing why, we’re all in trouble.
But I think PHP is still going to be used for many years to come. A particular framework that I use, Kohana PHP (http://www.kohanaphp.com), has helped re-invigorate my confidence in PHP and is enjoying some popularity.
i wasn’t at @media but it’s a shame people feel the need to carry on PHP bashing. Rails is great and has got a lot of people into decent web dev techniques, but PHP is a powerful, mature language which I would expect most serious web programmers take very seriously.
Of course part of PHP’s current unpopularity (or is “uncoolness” a better term?) is that a lot of people simply code PHP badly and there’s so much bad PHP out there on the web. The fact PHP just lets you get on with it quickly is both powerful and dangerous. It puts the onus on the developer to do things properly.
As Philip notes there is little best practise direction on the PHP.net website and it’s only recently with web frameworks like Zend Framework (http://framework.zend.com/) that “doing things properly” has been shouted about.
PHP is likely to get a better reputation once PHP 6 is out, with full unicode support and the ditching of a lot of unhelpful features like register_globals.
Conferences are great places to learn and meet people, but the trend is often on “cool” stuff which can be completely at odds with the reality of the “real” business world of the web. It would be nice for a bit more grounding in reality sometimes..
Did a post of this (check my name link), but the comments I received weren’t as nice as here 🙂
I think the title of my post says it all: “Stop Hating On PHP And Learn To Code Better”
Ugly, mangled code can be written in any language.
I love PHP and I keep reading people talking about how great Python or Rub on Rails is, that I thought I must be crazy for the fact I keep using PHP. You just convinced me that my next blog entry will be about some PHP snippet.
I agree with the image problem with PHP and think that some work could be done in this regard.
I wonder Rachel, have you ever considered writting a book on PHP like your HTML Utopia or even CSS Anthology? I would buy that in a heartbeat 🙂 The first thing I looked for when I wanted to buy a PHP book to start with is if you had doen one.
I came to PHP from ASP (before they added the .net bit), before there was any form of classes available. One of the first things I spotted when coming to PHP was CakePHP, which I didn’t follow at the time but should have and the PHP code I wrote at the time was pretty poor. Certainly there was a long lag in PHP between when PHP came about and when good frameworks became available (Ruby came after PHP but CakePHP is based on Ruby on Rails). As you say the strong bond between Ruby and Ruby on Rails is a great thing. It teaches good practice to beginners in the code.
I’ll never understand why two open source programmers would choose to needlessly criticise each other’s choice of programming language. I guess there’s always competition between the languages which leads to us-and-them camps, especially when you’re at a Ruby On Rails demo, but the speaker should have known better. It seems like Ruby has made efforts to improve on PHP which is great, but when you stand on the shoulders of those that went before you don’t do yourself any favours by trying to dig a ditch under what you’re standing on.