I was just wondering whether it would be worth sticking to non-OOP code for the sake of speed. Also, In commercial web-applications, is OOP generally used or avoided? Which is the standard?
The standard is to favor readable code over efficiency, because most of the time “more efficient code” runs faster by a single millisecond. Object-oriented programming is generally more readable than a non-object-oriented counterpart.
See also this question: Why are so many web languages interpreted rather than compiled?. The majority of a page’s load time is spent sending and receiving data or doing database things.
OOP is generally used in commercial webapps, and is turning to be the standard. The reason for it is not efficiency – it’s code re-usability, code readability, easy documentation, structure, and more importantly modularity!
Object-Oriented code is the standard, but not for performance reasons. It is really about maintainability.
Code speed is seldom of any real consequence in web applications. I/O is much more relevant, and most of the optimization people engage in is ultimately designed to reduce I/O:
- Persistent database connections
- Data fragment caching
- Page caching
- Client-side cache headers
Any significant CPU-intensive tasks are usually handled by compiled plug-ins, and made accessible to the interpreted language. Some common examples:
- PDF Generation
- Image manipulation (Imagik, GD)
- Cryptography (OpenSSL)
I think the OOP overhead is generally negligible for speed performance, and the code will gain much quality.
Commercial applications usually use OOP, if started after that was available (and stable!)