php[architect] logo

Want to check out an issue? Sign up to receive a special offer.

Stop Telling People to Optimize, and Start Teaching Them to Program

Posted by on June 25, 2009

I came across a post on the Google Code blog today titled “PHP performance tips” from their “Let’s make the web faster” series. As it often happens, this article relates primarily to what are usually termed “micro” optimizations—that is, small tweaks that you can make to your code to yield some measure of improvement in your performance or, as is the case with a number of the suggestion in the post by Eric Higgins, in the readability of your code.

This kind of discussion is not new—micro-optimizations tend to crop up in the community from time to time; it’s not difficult to see why: most performance problems are very specific in nature—they depend entirely on the particular way in which an application attempts to solve a problem. Therefore, the only kind of optimization tips that can be given in the generic context of an article can only be generic itself.

In principle, I have nothing against micro-optimizations; I just think they’re a waste of time—perhaps even more so because they take the focus away from the simple fact that it’s a rare performance problem that is cause by the language: the problem, almost inevitably, resides either with the developer, or with an external system.

Let me explain: the whole point of scripting languages is to shift the workload on external system. We rely on database systems to handle data management, and on other external libraries to perform tasks like manipulating graphics, interpret XML, and so forth. Whenever we are forced to do these things in PHP, we immediately come across performance problems because PHP wasn’t built for this purpose—much like developers come across problems when, for example, they try to use relational database as filesystems or full-text search engines.

Thus, I wish that authors of performance optimization guides would focus more on teaching people to better understand the role of each of the technologies they use instead of making them waste time replacing double quotes with single quotes. In other words, teach them to program… and they will learn to optimize.


Marco is the keeper of keys and Chief Garbage Collector at Blue Parabola. He can be found on Twitter as @mtabini.
Tags: , ,
 

Leave a comment

Use the form below to leave a comment: