Saturday, June 30, 2012

PHP - What Really Sucks About It?

PHP sucks. That's something I think a lot of programmers will agree on, even PHP programmers. For example, Jeff Atwood offers an interesting viewpoint in his blog entry The PHP Singularity. But heck, a lot of programming languages suck. And even though they suck, there are many millions of KLOC written in languages like COBOL, PL/I, and RPG.

Programming languages, like human languages, evolve. PHP started life as a web templating system, and evolved into a general-purpose programming language. During subsequent releases, new features have been added and some cruft deprecated. Other languages, like Perl and RPG have over the decades undergone similar transformations away from their original purposes.

Why is PHP so maligned? Perhaps because many of us have had to deal with PHP code written 10-15 years ago when the language lacked many of the nice features added in recent releases. Or PHP code written by programmers who knew better than the previous programmers on the project.  Or PHP code written by programmers without extensive programming experience. 10-15 years ago, programmers who knew the risks associated with web programming typically chose other languages if they could.

When I started doing PHP programming, I started with PHP 5 and CakePHP. With Cake, you can't help but structure your application using a more or less proper MVC design. It's probably too much trouble not to. And so I know from personal experience that it is indeed possible to write relatively clean code using PHP. Unfortunately, we don't all have the luxury of working with clean PHP code.

What kind of programming shop typically uses PHP? I would guess the typical PHP shop evolved as follows: The shop started out small, perhaps as a one-person company. As the business grew, the demands on the custom PHP application grew as well. Other programmers were brought in, each with their own programming styles. Perhaps one of them was assigned the task of managing the others. But without any significant management experience, eventually the programming staff gets to the point of running from crisis to crisis as the code base gets harder and harder to maintain. Does that sound like your PHP experience? It's a sure-fire recipe for job stress and significant staff turnover.

Based on my own experience, the next time I'm interviewed for a programming position, PHP or otherwise, I would come armed with a bunch of questions, including:
  1. Can I see your documents describing your development process?
  2. Can I see proof that the documented development process is followed?
  3. Would I be reporting to a manager with specific management experience?
To be fair, it's possible to write bad code in any language. But if a programming shop wants to grow beyond a small business, it needs to adopt a different mindset. It needs professional management experience. It needs proper coding standards and processes. It needs programmers who know what it means to work as a team. It needs a staff that understands the importance of egoless programmingCan those things be found in the typical PHP shop?

Cheers! Hans

2 comments:

  1. I think you've nailed the very question at the core of most of RPGs problems as well.

    ReplyDelete
  2. Proper coding standards involves not using PHP, ever, for any reason. It's the dark side, precisely because it's "quick, easy and free". Would we build bridges or cars according to the philosophy of quick and dirty? No, of course not.

    Nobody would drive cars like that or drive across bridges made that way.

    ReplyDelete