Friday, July 6, 2012

The True Problem With PHP

There's been a lot of traffic lately about what's wrong with PHP, and counter posts about how good it is. I've even fallen into the fray in an earlier article trying to step up and defend the language. The problem with almost all of these posts is that they focus on the language itself and what's wrong (or right) with it. This is not one of those posts.

The True Problem

The true problem with PHP lies in the community. Not the majority of the community mind you, but the fringes. The core of the PHP community is filled with a lot of really talented and smart developers doing some really amazing things. But on the fringes, there are a lot of people who are writing articles, tutorials, and posts designed to help beginners learn the language (and usually how to program). The problem with this is that the majority of those authors frankly don't have a clue what they are talking about. 

The simple fact that a site like w3schools still exists as a top result from a Google search is proof enough of that point. But if you watch the blog rolls often enough (or reddit), you'll notice that bad advice is all over the place. I've responded to a few of them myself. I saw another one pop up today, and decided that responding isn't worth the effort. People will still write them, and people will still read them. And that's a problem that we cannot ignore.

Why Is It A Problem?

This is something I've struggled with. On one hand, they have a right to post what they want. Who am I to say that they are wrong. But on the other hand, ignorance tends to cascade. Someone justifies their position by saying "I read it somewhere"... Then they teach that to other people. Before long the misinformation is spread so far that it's almost impossible for someone starting out to tell good advice from poor advice.

Even if we just look at tutorials talking about accessing data from a database, we get loads of bad information. It ranges from awkward (really poor code structuring and bad practices) to wrong (code that literally won't run), and from to bad (recommending deprecated functionality like mysql_*) to downright dangerous (code with major security vulnerabilities).

What Can We Do About It?

Part of the problem there is that there hasn't been a good, authoritative tutorial repository for PHP. There are tons of good blogs or resources out there, but they are buried in the weeds among the bad ones. And even the best authors and sites get it wrong from time to time.

I'm not really a huge fan of the idea that the php.net documentation should contain tutorials and non-language related content. I think the PHP docs are very good, but they are not really conducive to the style of tutorial that I think can really help. However, there is a format that the PHP community could adopt that would solve a lot of these problems. It's the same format that WikiHow adopted: a Wiki...

What I'm throwing out here is a simple idea: to start a core tutorial site as a wiki (perhaps tutorials.php.net). Leverage the community to provide content. Encourage people to post the tutorials to that site. Welcome any PHP related content. Let the community vet the posts, making corrections or pruning content. Over time, and with enough community support, it can become a valuable knowledge base of information.

What Do You Think?

Is the idea perfect? Absolutely not. Will it solve the problem? Definitely not. Can it help? Maybe, I don't know. The point is that the first step to fixing the problem, is to admit that it's a problem in the first place. I think it's a big enough problem to warrant reaching out to the community to figure out how to solve it.

What do you think? Do you agree it's a problem? Do you have any ideas how we can combat the spread of bad information? Respond on twitter, in a comment or on your own blog!