On PHP: There have been a lot of blogs jumping around on PHP in the last few days, and I’ve finally tracked it back to its source. Tim Bray — one of the “pillars of the Web,” if I can be so bold — posted about PHP a week ago. He mentioned about how much press PHP has been getting, then dropped this:
So here’s my problem, based on my limited experience with PHP (deploying a couple of free apps to do this and that, and debugging a site for a non-technical friend here and there): all the PHP code I’ve seen in that experience has been messy, unmaintainable crap. Spaghetti SQL wrapped in spaghetti PHP wrapped in spaghetti HTML, replicated in slightly-varying form in dozens of places.
And this is apparently where it all started. What’s interesting are the comments flying at Tim. He doesn’t have comments on his blog, so he’s manually adding them to the post because he’s been impressed with the discussion.
Adam Kalsey, I think, hits the nail on the head most closely in the very first comment.
[…] since PHP is easy to learn, is ubiquitous, and there’s lots of PHP examples on the web, it’s easy for a non-pro to pick up PHP and start monkeying with it. They learn bad habits and then publish their code and teach others bad habits. Some of the most popular open source PHP applications ever are really poorly coded. Gallery and WordPress come to mind.
And that’s the truth of it: PHP is so easy, that the barrier to entry doesn’t weed out people who write crappy code. Classic ASP is the same way — there’s a lot of heniously bad ASP floating around out there. And ColdFusion — I’ve seen some stuff written in ColdFusion that would curl your hair.
But at the same time, there’s good ASP — I’ve personally written some great ASP. I have a project now that I have to write in classic ASP, and I think it’s as good as you could possibly write something in ASP without resorting to COM. FogBugz is written in ASP, and I’m willing to bet it’s good ASP because Spolsky is a friggin’ ninja.
And, of course, the same goes for PHP.
I don’t want to beat a dead horse, but if you go back to my post on Camaros and PHP, you’ll see I was saying something along the same lines. More complicated languages like J2EE and ASP.Net have a higher barrier to entry — it just takes longer to figure them out — so the people who are going to write bad stuff tend to drop out and turn to something easier…like PHP.
PHP is therefore a victim of its own simplicity, flexibility, and ubiquity. I guess I can think of worse things than that.