First let me say I’m no PHP fanboy. I do consider PHP a very viable, powerful language, especially for smaller webapps. I think that PHP apps that get very big often become rather unwieldy — perhaps even if using an MVC framework. Can a project or team write great PHP code?
Yes, I think so, but I think PHP programmers are often flying by the seat of their pants, getting code out, and making it clean isn’t as high on their priority list — how is that for a generalization? It’s just, in general, not a big cultural objective in the PHP community. At the same time, someone can code in Python or Ruby, and it can be not so clean too. Yet the culture in the Python/Ruby community places more value on clean code.
See, one morning you got this high school kid writing on his blog how much he loves his Grandma’s apple pies, then in the afternoon he’s kicking open Notepad++ and doing some PHP code for his new WordPress plugin. Did he do any requirements, design, or test? Perhaps on the fly. Test? What’s that. Guess what? His plugin goes viral and now everyone is adding features and it turns into an even bigger mess. See what I mean.
Again, I think there is a stronger culture in the Python/Ruby community to write cleaner code. Frameworks are more commonly used in those cultures (like Django and Rails). I know there are many PHP frameworks and they are great too, but let’s face it, Rails — in particular — is awesome.
It is not unusual for some PHP projects to not use an MVC framework — the horror. In Python and Ruby, that would be less likely, especially in Ruby-land where again they have the infamous Rails MVC framework. Besides, isn’t Ruby a “cuter” name for a language than PHP — cute like watching kittens and puppies play together on YouTube. Have I just accidentally started bashing PHP? So sorry. Not.
However, with that said, I think bashing on PHP is silly. PHP was never designed to be a language used for large web applications. Although it currently runs some of the biggest ones like even Facebook. It was originally designed to be used by just one person for his webpage — that’s it.
It mushroomed into something much more, of course. I don’t think anyone can deny that PHP is also a very powerful language containing tons of code and libraries to boot.
Even Microsoft developed the ASP language with strong similarities to PHP. They have since moved to a more MVC-based language with ASP.NET MVC. Yes, again, with PHP one can be all MVC-like, but it is more common to stray from that paradigm — even if using an MVC framework. (I blame that on the historical PHP culture more than the language itself though.)
I do think PHP morphed over the years into a rather ugly language (C++ also shares some of this morphing problem — trying to be too many things to too many people). Everyone loves to bash on PHP though — way more than C++.
I admit the dollar signs can get old (influenced from the Bash shell), but don’t the “handle bars” or “mustaches” in Ruby get kind of tiring too — at least when doing template and web stuff (like when using the Ruby liquid templating library) — of course, when Jekylling? (Am I allowed so say that?) By the way, Ruby is one of my favorite languages so don’t go throw mud at me, please.
I’m a WordPress to Jekyll convert — who wouldn’t be. Well truth is I’m back to WordPress — at least for this blog. Lots of reasons but that’s another post. So PHP can be very powerful. I once wrote a static site generator in only about 100 lines of code.
I called it Cheetah. It was my little introduction to PHP project I made. It is a testament to the power of PHP as it only took, again, about 100 lines of code to make a basic static blog site generator. Obviously I didn’t make it generic or powerful like Jekyll though. One of my favorite things about PHP is that templating is baked in — besides having a huge library too.
Anyway, if you want to do serious web stuff, you probably would use one of the many other options out there. For example, Ruby, and to some extent Python, sure are eating away at the PHP market.
If only more shared hosting platforms would adopt Python (and especially Ruby), we would see the PHP slice get even smaller. Let’s face it. Does anyone really WANT to code in PHP? Isn’t it often just because we are trying to extend WordPress (Joomla, Drupal … yada yada) or host our app on a run-of-the-mill shared hosting platform that only carries PHP — maybe the host is even just running an old version of PHP?
You know, that low-cost LAMP stack that you brag to your mother you got for $8.99/month. I think it’s all about the right tool for the right job. For most serious web development, graduating from PHP to Ruby/Python or to Java/.NET is the way to go. Are there any banks that do transactional e-commerce stuff in PHP? Thought not. No, most likely they are using Java or .NET — faster, more secure and not PHP.