tags:

views:

787

answers:

5

I know it's a hot question that need anwsers ^^ From my viewpoint, using Java vs PHP, is nowadays a problem of system resources (Hardware, Software, etc.).

For Java, you have to deploy J2EE Stack (JDK, AppServer, etc.) (~200M) on your server, for PHP you need to deploy a LAMP system (~100M). Using Java was in my opinion due to object oriented programming in web application, but today we have a lot of Object Oriented Web Language (Ruby, Python, PHP).

So the question when to choose between Java or PHP for new projects ? Maybe the community difference ?

I know that stackoverflow is not made for discussion, but it's a (good?) question that need answers (for me and for others maybe) ^^.

+1  A: 

It depends on what you're doing. Choosing a language/framework without analyzing your project requirements is a bad idea.

Quotidian
I know but if a project is realizable with both technologies, which one do you choose ? and why ?
Zenithar
+1  A: 

Choosing a language depends on what you want to do, but I am very sure, the different harddisk space requirement will be the least important aspect of your decision.

Here is a possible hint: If you want to reuse your work (or parts of it) in a desktop application, use Java. PHP is virtually non-existent for everything except web programming.

GodsBoss
+4  A: 

Other constraints are usually taken into account. Things like

  • development time,
  • maintainance cost of the codebase
  • availability of qualified programmers
  • salary cost for available qualified programmers

to name a few.

Hardware and software are cheap if you compare them to the above so they tend to be less important.

Jacco
Yes i'm agree with you, hardware subject was only an example.
Zenithar
A: 

I really don't think that it is a question that can objectively be answered. In the end it is about people and what they feel more comfortable with. That is why e.g. Facebook developed a PHP to C++ compiler (with which the performance benefit that Java has might become smaller, too) instead of just hiring C++ developers for doing the Job.

On the other hand, the Java platform offers some interesting new approaches like Grails (which is basically a Groovy Wrapper around Spring) and Lift, as well. That makes Frontend development faster and easier (I still find that this is a real pain with plain Java) and you can combine the benefits that other languages have with your existing Java codebase and expertise (btw. most of the Frameworks mentioned don't need a J2EE runtime environment a simple Tomcat installation with around 5M and an installed JRE should be enough). So it is not really about the Java programming language alone anymore.

And if you really can't decide at all you just run PHP in Java (works as well for Ruby, Python, Javascript ...).

Daff
A: 

I do not really agree on the fact that the choice of a language is related to system resources.

Hardware is cheap and we are not in a time where we need to closely look at the system resources as we used to have. Don't misunderstand me: we still do need to pay attention, but the time where people were xoring their pointers to save some space is over (luckilly).

And if your main concern is performance, then either running a JVM or an interpreted language is probably not the best option.

I do not think it is related to the orientation of the language per se either. Ok, I know, PHP is not object oriented but still, you can now code OO with it. You will find descent web frameworks for almost any language.

I agree with Jacco on his list.

Another aspect is indeed the culture the language refers to.

PHP is for script kiddies. Java is for serious, wearing suits business developers. Of course, we all have many counter examples but still. Java was largely adopted by big companies, now competited by .Net. There are good reasons for this, among which the fact that it a lot easier to write poor code in PHP than in Java (and almost any other language). On the other hand, Java is not exactly freedom oriented.

I your project is strictly personal, you can choose whatever suits your tastes better. If you plan to develop as a team, the choice of the language will impact its general mood/way of thinking.

I would finally add some important parameters to me: fun and elegance

This may be a matter of taste here again, but I have much more fun coding in python than in C# for instance.

Benoit Vidis