PHP Sucks!

Software development is a remarkably fashion driven industry.  I’m definitely guilty of the default “newer is better” mindset that many technologists have, but one of the more bizarre fashion statements I hear constantly nowadays is “Oh, I mean, you know how PHP sucks.”

I hear it at conferences, from developers old and young, in companies large and small.  Modern languages like Python and Ruby are better designed, maybe have cleaner syntax, have a few features that PHP does not, maybe even better library support, and they’ve got Rails and Django.   It’s natural to conclude that PHP Sucks!

A few years ago when we started incorporating Ruby into our platform, this gospel was so well ingrained that when we found that long-running scripts chewed up a lot of memory we blamed PHP.  Because it sucked!  People were actually rewriting scripts into Ruby because they could run for a day without running memory, until someone noticed that there was a leak in our internally built database abstraction layer (wich Ruby didn’t use), fixed it, and made PHP suddenly so much better.

But when I talk to developers and hear that statement, I like to drill in on why they think PHP sucks and here are the common reasons, in no particular order:

  • We use PHP it at work and there’s so much legacy garbage code.
  • PHP encourages bad programming.
  • PHP doesn’t have the developer mindshare that Ruby enjoys.
  • All the best companies use Python/Ruby.

PHP is older.  It has a good 5-6 years on Python and Ruby and that includes an incredible amount of growth for the web.  It was heavily used prior to frameworks and Ajax and Web2.0 and standards around TDD for the web.  Legacy garbage code is not the fault of the language, it’s the fault of the developer.

PHP does not encourage bad programming.  Bad programmers or bad organizations encourage bad porgramming.  Blaming PHP for our lack of discipline is setting everyone up for failure the second time around with a different language.  I’ve seen just as much bad Ruby code as PHP, it’s just there’s usually less of it because there’s only been a few years for the Ruby stuff to accumulate.

PHP doesn’t have the same developer mindshare on the cutting edge, at least as far as I can tell, and there is some merit to the idea of using what is being progressed, but there are good PHP alternatives to a lot of the key cutting edge Ruby or Python projects.  Looking for a good framework?  Check out Symfony2.  Behavior Driven Design guys should check out Behat.  Heroku and several others now support PHP.  My guess is that “new car smell” of a new framework and new project is what people are really after.  Spin up a new project on PHP and use some of its modern conveniences and see if you agree.

Many good companies use Ruby or Python, many use PHP.  Here’s a company defending its use of PHP a year ago.  There are still more lines of PHP code out there in some really great products written in PHP.

Bottom line: PHP doesn’t suck.  Guns don’t kill people and neither does PHP.  I’m not saying that Ruby and Python and PHP are all equivalent, but I am saying lets put down the fashion statements and really say what we mean.  Without truly understanding our reasons behind language choice, we’re doomed to make really stupid mistakes like the anecdote above, and faulty decision making processes that hide true requirements produce bad decisions.

I also like trying new things.  My last two projects were a Rails and Django project.  But when asked why I was using them, I said “to learn” not “PHP Sucks!”  

 

1 thought on “PHP Sucks!”

  1. Agreed. Instead of whining about how a language doesn’t enforce you’re own programming pet peeves, just program better. I have only minimal experience with Ruby and Java, quite a bit of experience with Coldfusion, tons of PHP. I like PHP best by far. I once developed a small app in PHP for a company that later converted it to Java. Apparently they were "surprised" at how good the code was because, apparently, someone couldn’t possibly write good code in PHP. I hate inflexible languages and prefer to make my own conventions where they make sense. Chris, I don’t know you, but hopefully you’re not as stupid as the guy that wrote the post you linked to. Most of his "reasons" are personal pet peeves that can easily avoided if you so desire, or ways the language worked *until* version x.x. I feel a blog post of my own coming on …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s