ifacethoughts

PHP Sucks, But We Can Only Rant, Not Avoid It

There is lots to listen on the PHP channel nowadays. Bashing, bashing; sometimes praise, and then some more bashing. This post is more of a justification to myself, especially after reading all these posts, about how PHP still works and how as a Web developer I cannot avoid it.

Programming and Templating

It all becomes too controversial till you realize that PHP is being talked about from two different angles – as a programming language and as a templating language.

Only a programmer who is passionate about writing good code can spend time in bashing a programming language. By good code we mean predictable, consistent, maintainable code. PHP, as a language does make it difficult to write it. You have to take an extra effort to avoid the pitfalls, absorb the shocks or the surprises and take in the inconsistencies. I can identify with this. I like good design, good code and PHP will not be my choice if I want to deliver that.

However, I still end up working with PHP. Sometimes the client knows PHP (or thinks he/she knows), sometimes you have to deploy the code in a dollar shop hosting environment or sometimes you have no idea what kind of budget will be available for this exercise. So you choose PHP – the cheapest of all – to do it. You have a static Web site and you want a contact form. You check and you will find PHP support on the host. You crank out the HTML, insert PHP code, make it pretty using CSS and maybe even JavaScript frameworks, and you are done. I can identify with this as well. This is PHP at its best as a templating language. I am sure every Web developer has come across a PHP project at least once.

Unfortunately, this ease of use creates difficulties as project evolves. The templating langauge starts to crack, you start to look for more engineered solutions to complex problems. If you stick with the inexpensive resources you had, you end up with horrible unmaintainable sphagetti code. If you go to hire better programmers you have to go for more than better because using PHP now involves working through the programming language problems in addition to the previous avatar of your sphagetti code. PHP starts to suck.

A lot of PHP projects go through this. But a lot of these PHP projects are also successful. PHP, as a programming language makes it difficult, but it also makes it easy on a lot of other fronts. PHP sucks, but some people continue to deliver good code and good design with it. Success makes it addictive and it doesn’t matter any more if PHP is a bad programming language. Meanwhile some of us keep bashing PHP, venting out the frustrations, hoping that we will get to work with a better PHP someday.

Discussion [Participate or Link]

  1. Daquan Wright said:

    I definitely agree with those points. It was developed by one man to solve his problems, it wasn’t carefully designed to be a world class programming language. But like JavaScript (who suffers similar issues), if we know the bad parts it’s a lot easier to avoid them.

    Scrape away the ugly, and deploy PHP where it makes sense. :)

    Personally, I dig Python as a programming language.

  2. Shal said:

    You can easily avoid PHP by using HaXe – it allows you to compile to lots of platforms, including PHP.

Say your thought!

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
My bookmarks

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.