Mike Conigliaro

PHP Considered Harmful

I know what you’re thinking. “Not another anti-PHP blog post!” But instead of complaining about specific deficiencies in the language, or how I think PHP encourages you to be a bad programmer or whatever, I want to talk about a fairly eye-opening conversation I just had with a friend. We were talking about possible optimizations for some of our Project Euler solutions. Since I don’t have enough of a background in number theory to come up with many of those kinds of tricks, I suggested that threading might be a simple way to make a big difference for some problems.

Friend: “I don’t know what you’re talking about.”

Well, for example, instead of iterating through a huge range of numbers with one giant loop, you could break the range up into several smaller ranges (according to the number of cores on your machine), then run your algorithm several times in parallel and just sum up your results at the end.

Friend: “Haha, I still have no idea what you’re talking about.”

And then it dawned on me; my friend doesn’t have a formal computer science or engineering background, and he’s been working with PHP (a language with no concept of concurrent programming) almost exclusively for about a decade now. He’s a smart guy, and not what I would describe as a stereotypical “bad PHP programmer,” but the fact that he hasn’t spent much time with any other languages means he’s never been exposed to this very fundamental concept in computer science. Now, I’m fully aware that most web developers don’t normally have to deal with concurrent programming at all, but I still think it’s something every programmer should have some rudimentary knowledge of. And I’m willing to bet that if my friend had been working with Python or Ruby all these years, he would have at least seen some mention of threads in library documentation or someone else’s code.

But maybe the point isn’t just that PHP is harmful. Maybe it’s that spending all your time working with any one language is harmful. This conversation made me wonder what kinds of things I might be missing out on by spending all of my time working with Ruby and Python!

blog comments powered by Disqus