I was cleaning out my Twitter favorites today. (I generally use my Twitter favorites as a ‘bookmark’ or a ‘read this later’ device). Anyway, I came across this tweet:
This got me a little riled up.
First, the sentiment that his code sucks is one that I can totally sympathize with. I’m very insecure about the code that I write, and I always see room for improvement. I’d refactor and refactor forever given the chance. So, it says something that the creator and developer of one of the most popular and (I think) well-crafted sites on the web (stackoverflow.com) even feels insecure about his code (which I’m sure is much better than he thinks).
Second, Atwood is one of the most outspoken PHP critics on the web. He does understand that building a compelling app is more important than the language it’s written in, but his hatred of PHP still endures.
I’m here to say that PHP, as a language, does not suck. It has flaws, yes, but it is a real, viable language. Here are the things that I think makes PHP an excellent choice for building your next web app:
PHP is a language that is easy to learn. (This is also a downside). Any schmuck can start writing a web app in minutes with some cheap hosting and a text editor. This means value can be delivered very quickly (something that I’m sure Joel Spolsky appreciates).
PHP is arguably the most well-documented and completely documented programming language. The documentation available at php.net is nothing short of astounding. Each function/class has a description, parameters, examples, ‘see also’ links, not to mention a comment thread going back years with examples and tips.
PHP is popular and open source, and therefore it’s a language that is constantly adapting and improving. This can also be a downside: naming conventions and best practices aren’t 100% consistent, stuff gets deprecated, and some people aren’t comfortable with that. Totally understandable.
There are great, mature frameworks and platforms for PHP (CakePHP and WordPress, for instance), which I’ve found can be very helpful for reducing the downsides of PHP and magnifying the positives.
So that’s my case for PHP. I don’t think it deserves nearly all the crap it gets, and I think it’s one of the top used languages in the world for good reason.