I'll take a crack at this but first a disclaimer - I've been a J2EE engineer for about 6 years now and have only done PHP on the side so read my answers knowing my potential bias.
Quote:
| Originally Posted by macdum 1. Which is easier to learn PHP or Java? |
From a pure language perspective I guess it depends. PHP 5 finally introduced some true object oriented capabilities. However, some would argue that learning OO at the same time as learning syntax is harder. So if you're new to all programming Java might be slightly harder as it
requires OO concepts. PHP has more of a C and Perl flavor and relaxes many of the things that catch first time programmers.
Quote:
| Originally Posted by macdum
2. Which is a more robust language PHP or Java?
|
A loaded question if I ever answered one. I would argue in favor of Java on this one but only slightly. The JVM (Java virtual machine) prevents many of the types of things that languages like C allow but really so does PHP. In this case it is really the environment (i.e. J2EE or PHP in an Apache environment) that makes one better or worse. The
language does not really contribute to the quality.
Quote:
| Originally Posted by macdum
3. Which is faster PHP or Java?(performance of comparable scripts) |
Out of the box I would say Java. You need to understand more about Java than your question implies you do. Java is a precompiled language, unlike PHP. PHP, out of the box, is a 100% interpreted language. Java is partially interpreted. Modern JVM's have things like just in time compiling that drastically improve the performance of long running programs. PHP has commercial and non-commercial add ons that also help improve performance by allowing the engine to parse the script once and cache that information.
Quote:
| Originally Posted by macdum
4. Which is more secure PHP or Java?
|
Again, I'd lean towards Java but also again, it is more of an environment issue. Both languages protect against some misuse though I think Java does a bit of a better job of it. Java allows someone shipping a library to "sign" the code - the end user is then able to certify that the code came from the correct place. PHP does not have the same built in mechanism.
Quote:
| Originally Posted by macdum
5. Which is better PHP or Java?
|
What is best for me may not be best for someone else. For example, if one of the criteria I use to choose a language is that it is trivial to change from one hosting provider to another then PHP would be a better choice - there are a ton more hosts out there that support PHP than Java. So the answer is "it depends". Why not C? C++? Python? etc, etc, etc. In some cases something else may make more sense.
Again, I've been using Java for a while now. In the old days PHP was a fairly simple scripting language. It has grown to be truly production caliber. The same can be said for Java. Very large sites with 10's of thousands of hits per second run Java. The exact same thing can be said of PHP. In the end it is up to the architect of the system to figure out which would be better for a particular installation.