Java – PHP and performance

javanetPHPspeedweb-development

I always hear that PHP is for medium and small websites whereas .NET and Java for enterprise applications. My question is about PHP. Why is PHP not a good option for enterprise web applications? Is it because if the web application becomes bigger then PHP will be slower as it is an interpreted language?

I know that corporate world will choose .NET or J2EE because of the integration with their products and because of back end services, etc. However, if we just have PHP for building sites and web applications then how can we use it to perform well with big sites?

In short, Is there a relationship between the performance of PHP and the size of the website?
What are the factors that make PHP not appropriate option for big sites?

Best Answer

Performance is probably not one of the factors. For a dynamic language, PHP actually performs pretty well; depending on the task, it might or might not beat other technologies. The application model simply is too different to compare it directly against Java or ASP.NET. Even if there is a measurable speed difference, it is not big, and it's probably linear, which means it can be solved by throwing more hardware at it. Also, the programming language itself is seldom the bottleneck - algorithms, database access, network bandwidth, and I/O in general are the usual culprits, unless you are writing somehing truly CPU-intensive.

Reasons for using ASP.NET or Java over PHP that are more likely include:

  • Platform integration. ASP.NET offers extensive integration with .NET and the underlying Windows OS.
  • General purposeness. PHP was designed specifically for the web, while .NET and Java are general-purpose platforms. Using Java or .NET, you can tack both desktop and web frontends onto the same shared code with little effort, while PHP isn't very suitable for writing desktop applications.
  • Code organization features. Java and .NET were designed for OOP from the start, while OOP in PHP is somewhat of an afterthought. PHP introduced namespaces very recently, and they are limited and clumsy compared to what .NET and Java have to offer. Enterprise-style programming usually relies heavily on OOP, which makes PHP the lesser candidate.

Another reason for the perceived effect is that PHP is free (as in beer) and ubiquitous - every cheap shared web hosting company has PHP in their standard package, but a .NET or Java server is going to cost you significantly more. Consequently, a huge mass of small websites uses PHP, not because it's the best tool for the job, but the only one at hand.

That's not to say PHP is unsuitable for large projects - it just doesn't go well with the 'enterprisey' kind of programming. Its strengths lie elsewhere, and if you can leverage them, you can just as easily build large-scale applications as you could with any other web technology.

Related Topic