The Php Debate

I was thinking about my next post, when I ran into “The PHP Singularity” from Coding Horror.

I’m a big fan of Coding Horror as it is one of the best developers blog out there, and in this post he makes it clear that he thinks PHP as a “double-clawed hammer”:

I can’t even say what’s wrong with PHP, because – okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.

You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.

You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.

You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.

And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.

Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.

That’s what’s wrong with PHP.

(go there and read the whole post)

Well, it’s his opinion, but I think that his opinion is wrong :), for several reasons… that’s the main idea in this post. So let’s go!

The Bad Parts


PHP is a scripted language. Trying to interpret and define and create and instantiate and blablabla during the request is slow.

Two systems running, one in PHP and one in Java, both doing the same thing: Java will be WAAAAAAAAY faster.

The nephew effect

Client: “So, how much it will cost?”

You: “It’ll cost X, and will take Y time.”

Client: “Go to hell! My nephew does this in half of the time and with X/10 cost!”

Sounds familiar? Yeah PHP suffers this A LOT, and it is nothing that happens with Python, for example. Almost anyone can code in PHP and you can imagine what will come out of this, wich brings us to…

The “legacy”

I can tell you three or four stories of “add one or two things in my aready running system, written in php”, all of them ending with me, laying in fetal position under the table and crying for my soul, but that’s just sad.

The big point is: since PHP is simple and quick, everybody can open a php file and add something, and by everybody, I mean EVERYBODY.

That leads up to some awful pieces of code, running now in production that you’ll have to take a look and fix (or, more probably, rewrite and hope it doesn’t break the system).

The Good Parts

The learning curve

Due to it’s simplicity, PHP can be taught and learned really fast. If you write an html form that posts in a script that saves in a database, well… you code in PHP! Yey! Go tell your mama!

The Comunity

With so many people programming in PHP, it’s community is vast and generous. You can find answer to all your questions on foruns, or on stackoverflow.

And since it’s so damn simple, you can make the most stupid question of the world, and no one will call you “dumb ass”

The Borg Factor!

( If you aren’t a fan of Star Trek, Borg is a race that grows and expands indefinitely, absorbing anything in the way… yes, I’m a big nerd )

Php is always growing, both language and comunity. The secret to this is simple: almost every server, anywhere in the world can run PHP. I think every hosting company put php as default. Damn! Php can run as an Apache Server module. All this with minimal configuration… run apache with the php module, copy a php file into the server root and it works. Seriously, you can’t get better than that.

And the language, as is…

As said before, Php is pretty simple and straightforward. A variable starts with “$” and can be of any type (and can change type in runtime), even a function. You can run without defining classes and objects (non-OO aproach), or (since php 5) build your entire system over the OO perspective. Therefore, a VERY flexible language.

PHP has a lot of frameworks to do the job, cake, zend, magento, etc (just to name some of fullstack). Either you want some “already made” tools, or some magical code that makes the whole system work, php got it. You can spend a good time, just to find the best framework for your need.

And the last comment: Composer. Now Php got a (real) dependency manager for your project. For a old school php dev as myself, that’s something really cool \o/

Well, in the end it’s just the “right tool for the right job”, and php is not a double-clawed hammer. 

Given the scenario PHP is the best tool to be used. Give it a try and let’s talk about it later

Leave a message

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

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

Google photo

You are commenting using your Google 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