1

All of us know that Java on the server required JVM then it goes to machine code while php does not need this.

From this point of view, can we say that php will perform better on a server than Java??

If Yes, by how much approx the resources used by java is more than the resources used byphp ?? is it 150% more or 110% more??

4
  • 1
    Decide by reading stackoverflow.com/questions/3975691/… Commented Jan 6, 2011 at 19:27
  • 1
    Quite frankly "All of us" know that PHP on the server requires a PHP interpreter of some sort; PHP is not a compiled language. Commented Jan 6, 2011 at 19:50
  • Ya of course but it compiled to machine code while there is more layer, JVM thus instead of one compilation for php, we have 2 compilation for java Commented Jan 6, 2011 at 19:55
  • 1
    Actually we have two compilations in PHP: PHP Code -> Opcodes -> Machine Code. This is done upon every request. By adding an Opcode Cache, you can reduce this to just one compilation (after the first time), which is kinda-like how Java works. The developer compiles to JVM-code, and the JVM to machine code. One compilation to serve the request. Not saying that Java is better though - that (as always) depends on may other factors. Commented Jan 6, 2011 at 21:08

3 Answers 3

4

Java is a lot faster than PHP (5x-10x), but it is also more memory consuming(usually, but not always), approximately 2x. But my opinion depends on software applications i`ve seen. It is never true to say that Java is better than PHP in all ways and everywhere. In my work we use Java for heavy business applications (Tomcat 6 with Terracotta clustering), and PHP for small-medium sites and frontends.

Sign up to request clarification or add additional context in comments.

2 Comments

so from your statistics we can say that Java will better since memory resources is cheaper than processor resources
Yes. For our case we deciced that CPU resource is more important.
1

I think you should still consider PHP, especially since more and more nice PHP compilers are starting to emerge.

From the beginning there were opcode cachers, like bcompiler or zend cahche, and they increased performance with 5x - 2x, but now there are things out there like http://developers.facebook.com/blog/post/358, more real compilers that seem to translate php code to lowlevel instructions, which must be almost as fast as a Java-equivalent. (A search on "php compiler" would get all the available options)

So php is not that bad anymore processor-wise.

Comments

1

I work at a large global corporation and we are dropping Java like a hot rock. We've gone years with large teams developing Java Web applications only to find that one person with php can outperform a team of 5 java programmers. Java is extremely unproductive by a factor of 10 (our experience). As far as performance, some php frameworks out there are slow. That's the framework NOT php. We have our own high performance PHP framework and its about twice as fast as our java web applications.

In addition, PHP is improving its technology at a rate that far exceeds Java. Java has a bloat problem which can't be resolved because the language maintainer OWN the class libraries.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.