I work in a PHP based company. There is a project where we want to create a backend service. Senior members here are going for PHP, even though it is slower than Java. Their only point of contention, that Java is heavier than PHP in both memory and cpu load standpoint.

Jvm is more like a container environment, if u bring in more baggage it will consume that much, but service we are talking here will be of medium complexity. So chances are that it won't be much demanding (or will it?)

I understand this question leans heavily towards vagueness, however my point of ponder is, that is it always the same case? That java is more hardware demanding? I would just like to know opinions of all you experienced folks about how the actual scenario looks like.


If you're worried about speed, write the back-end in a compiled, fast-as-you-like language such a C or C++. There are plenty of webservice tooling to create simple C/C++ web services that you can consume from your PHP clients.

However, if you want to code it quickly and performance isn't so bad, then write it in PHP. You also have the benefit of already having the skills necessary to do this, so that's a double bonus.

Java isn't massively bloated compared to PHP, it might be a 'step up', but you'll have to learn all the niggles and tricks that you need with any new system, and I doubt the benefit will be worth it compared to just writing it in PHP straight away. In most cases, if you have the skills to do it in PHP already, that should be the first choice, choosing to do it in a different language away from your main area of expertise should be very carefully considered and only chosen if there is definite benefits over your primary system (which I don't think there will be in this case)

|improve this answer|||||
  • How about compiling PHP? – Виталий Олегович Mar 6 '13 at 13:29
  • 1
    using Hiphop or Phalanger? Could work, but the CPU instruction speed is usually not as big a performance issue compared to how the language works - cache hits, memory usage and IO is more important nowadays. Either way, you do highlight that PHP is a better choice than Java for them. – gbjbaanb Mar 6 '13 at 13:33
  • 1
    I think that if most of them know well PHP and they don't need very high performance, then PHP is the best language for them. – Виталий Олегович Mar 6 '13 at 14:08
  • 1
    I wish people would stop suggesting "compiling PHP". HipHop does not compile PHP. HipHop is a source code transformer from PHP to C++ (Which is then compiled using a C++ compiler). HipHop is a solution to choosing the wrong language for the task. – Craige Mar 6 '13 at 15:29
  • 2
    @Craige: actually, HipHop no longer compiles to C++, it's now a run-time JIT engine: github.com/facebook/hiphop-php/wiki – Joeri Sebrechts Mar 8 '13 at 10:30

Many enterprise Java shops tend to add a lot of abstractions and frameworks (such as ORMs, EJBs, spring, third-part libs, containers etc) to their systems. Sometimes these abstractions are meaningful, but often they end up adding bloat (memory, cpu) and complexity.

PHP, otoh, can be used pretty much "as-is", warts and all. But with Java you certainly need to juggle a lot more parts.

So you need to factor in those other things as well before making a decision.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.