Archive

Archive for February, 2008

One of the main reasons that so many PHP-coders suck at programming?

February 2nd, 2008

I was about to just write a very small thing in PHP, and wondered what the nicest way to get a random string i PHP would be (lacking a nice sample method like in python) and googled “random string php”.

I found this.

Just… what is that? It just might be the ugliest piece of code I’ve ever seen. Not only does it have a nice little switch statement for each letter in the alphabet, for some reason the coder also seeds the random seed for each iteration in the loop.

This might be the worst I’ve seen, but I’ve seen a lot of PHP example code that is pretty close, and I think that this might be one of the main reasons that a lot of PHP-developers produce unreadable code (have a look at tbsource among other large projects for some horrifying code).

It’s nice that people like to share their code to teach others, but you are more likely to hurt development if you don’t have a clue what you are doing.

I’m not saying that all PHP-developers are horrible programmers (because they aren’t), and I use quite a few PHP-applications myself (such as wordpress) but the ratio of bad code compared to other languages seems to be way above average.

buffi Programming & scripting