Tuesday, April 10, 2012 [Tweets] [Favorites]

PHP: A Fractal of Bad Design

Alex Munroe:

Virtually every feature in PHP is broken somehow. The language, the framework, the ecosystem, are all just bad. And I can’t even point out any single damning thing, because the damage is so systemic. Every time I try to compile a list of PHP gripes, I get stuck in this depth-first search discovering more and more appalling trivia. (Hence, fractal.)

Update (2012-04-22): Jesper:

For the rest of my life, barring something even better, I will carry around that link to use when people ask why I hate PHP. A third of the text could be slander and a third out of date and it would still be enough to keep me away. It may run the Internet, but it does so in spite of itself, and not because of itself.

7 Comments

FWIW, as a non-coder, bad languages are the only computer languages I can get anything done in.

I can get stuff done with AppleScript and PHP, which are two languages every coder seems to hate. I like BASIC too.

I believe this pattern to be non-coincidental.

@Chucky I think the aspects of PHP that make it possible for you to get stuff done are for the most part not the parts we’re complaining about. That is, if PHP hadn’t made these mistakes it’d be even better for you.

I’m not an AppleScript hater.

BASIC was my first language. It’s fine at what it is.

"I’m not an AppleScript hater."

Really? Then you must be the only coder on Earth who feels that way, from what I can tell.

(And I don't mean not seeing the beauty in implementing AppleScript in your apps for folks like me. And I don't mean not seeing the beauty of being able to do Mac system level automation for yourself using all the provided hooks. I mean in how you love/hate AppleScript grammar and the such, as a language.)

"That is, if PHP hadn’t made these mistakes it’d be even better for you."

You may well be correct. I have no way to have an informed opinion on the matter. But as Eevee notes in his quite entertaining rant:

PHP was originally designed explicitly for non-programmers

I find it hard to believe there isn't something fundamental baked in there to create its suckiness for coders and utility for someone like me.

In the non-computer world, pidgins are bad languages, fractally bad, one might say. But there are folks for whom "fixing" a pidgin would break its usefulness. I have no way to have an informed opinion on whether that analogy is appropriate for PHP.

@Chucky AppleScript’s grammar is fine. Not that I’d want to write a whole app in it, but it really doesn’t bother me. As I see it, there are two main problem areas: (1) the core data types are missing commands that are built into almost every other language; it’s way too much trouble to do a string replacement, sort a list, basic stuff like that. (2) it’s finicky about when one syntax will work vs. another, based on implementation details of the app you’re targeting.

PHP’s suckiness is because it started out as a bunch of tools that were not even intended to be a language. And then it attracted a lot of people who were either non-programmers or programmers who were not experienced with languages or making good APIs. I think a bad culture is self-perpetuating. To anyone interested in a nicely designed language, it was obvious early on that it was too fundamentally flawed to be fixed, so why try to be part of that community?

“I find it hard to believe there isn't something fundamental baked in there to create its suckiness for coders and utility for someone like me.”

I realize that sounds logical, but I’m pretty sure it’s not the case.

A lot of valid critique of PHP but I also think Anthony Ferrara is making a good case here:
http://blog.ircmaxell.com/2012/04/php-sucks-but-i-like-it.html

(And for me, being a happy amateur PHP hacker I actually like when "real" programmers point out and explain problems with PHP, since it's not something that you automatically know if you're not a programmer and have limited knowledge of other languages.)

@Adrian I think Ferrara’s main good point is that it’s easy to deploy, and that’s probably what led to it gaining critical mass. I’ve never found popularity arguments very convincing. The fact that WordPress’s codebase is a mess shows that code isn’t the only thing that matters, but it doesn’t mean you should emulate that. I would argue that an underpowered and error prone language makes it more likely that you’ll end up with messy, buggy code.

Probably because part of WordPress was designed by people like me :)

When I started with PHP in 2000 I came from a world where Server Side Includes (SSI) were a hot thing. So the new world of PHP opened up a lot more opportunities - to do both great things and messy things.

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment