File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes PHP vs Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "PHP vs Java" Watch "PHP vs Java" New topic
Author

PHP vs Java

bob reilly
Ranch Hand

Joined: Jan 22, 2007
Posts: 44
I don't know if this is the right forum to ask but here it goes. Staff at my office are familiar with PHP. We are literally just getting off the ground in learning Java. The question - what's the benefit to learning Java. We're a local government organization - with a need for Internet application to interface with enterprise database.

PHP seems to be a very straight forward scripting language with objects that you become familiar with. Java seems more involved. Whats the benefit of Java over PHP.

Any comments you could provide would be appreciated. Thanks.
Alonso Faust
Greenhorn

Joined: Dec 19, 2007
Posts: 14
Well first off, PHP is solely a web-based programming language; it's use is limited to web pages that exist on a PHP-enabled server. Java on the other hand can run from within a web page or completely independent of the internet whatsoever.

Secondly, and probably least important but as it leads to Thirdly I shall include it, PHP is a much less strict language than Java, and as such can lead to poor programming practices. e.g. I worked in a language called AutoIT where it doesn't require line/command delimiters or even initialization of variables. It took me months to remember to put ; at the end of every line and I'm still not entirely re-used to setting variables to null or anything else.

And thirdly, while certain languages can incite poor programming habits, understanding and having worked in a large selection of languages can only increase your knowledge and ability as a programmer. And as a miniature fourthly, the more programming you understand, the more efficient your code can be. ("Never underestimate assembly language" ~Michael Saladino, Presto Studios)

I'm not trying to sound harsh in any of this, but there's ALWAYS an upside to learning a new language.


"It is but the bedazzlement of the Great Enchanter which makes the Terrible Giants appear as windmills, to the untrained eye."
Jeremiah da Costa
Greenhorn

Joined: Nov 29, 2007
Posts: 12
We've had this come up at our company but it was not with PHP that was thrown out. It came down to Flex and Java. We decided to go with Java for the simple fact that we could leverage the Eclipse IDE and distribute our solution in a J2EE environment. Now with that said, we can achieve the same with Flex (some may argue otherwise) but if we ever wanted to have a stand alone solution with Java we are able to do so. So really, it comes to requirements not only now but future.
Andrew Mast
Greenhorn

Joined: Dec 22, 2007
Posts: 4
One thing I've noticed is that PHP doesn't have the same strict rules that Java has with regard to primitive and other variable types. Java has strict type rules so that casting is expected if changes to a data type are to be made. PHP sort of let's you do anything which is flexible but also leaving you (the coder) with a lot of validation and possible runtime errors to deal with.
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20494
    ∞

My experience with PHP is pretty limited. I have about 20 hours of experience with modifying existing PHP apps.

In order to give some weight to the opinions I am about to express, I want to say that I have experience with dozens of languages, including 11 years of C/C++, and a plethora of scripting languages including an intense year and a half with Perl.

The real power and beauty of Java is:

<ul>

1) When your apps get big. Java does big better than any other language.

2) When you work with other engineers. No other language smooths the road better for many engineers working on the same app.

3) Readability. Java is the best for when you have to come back to your own code that is two years old.

4) Less bugs. It takes more time to write the app than if you used a scripting lanaguage, but your odds of it working right the first time is much higher.

</ul>

I think the list goes on and on with all sorts of great reasons why Java is the best language for damn near anything. But .... I am now a Java bigot.


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Originally posted by paul wheaton:
1) When your apps get big. Java does big better than any other language.

Nonsense. You can write the same app in most other languages just as well, possibly with the help of some third party libraries to replace the Java API.
Why is Java better? Because of packaging? Because of separate files for separate classes? You can do the same in C, C++, Python and dozens of other languages.

2) When you work with other engineers. No other language smooths the road better for many engineers working on the same app.

Again, nonsense. You can distribute the workload exactly the same in Java or C++, for example. The keywords for working together are communication and proper project managent. If either one is missing, the entire app will be doomed, whether it is written in Java or not.

3) Readability. Java is the best for when you have to come back to your own code that is two years old.

Do you really believe yourself here? Again, this is just the programmer having a consistent coding style. You can achieve the same in almost every programming language.
To be honest, if I would choose a single language that improves, encourages and even enforces readability, it's Python - you have to maintain the same indentation for an entire block, or it won't even run. In Java it's very easy to screw up indentation, thereby screwing up readability.

I think the list goes on and on with all sorts of great reasons why Java is the best language for damn near anything. But .... I am now a Java bigot.

And it couldn't be more obvious.
I too am mainly a Java developer, just because it's powerful and easy. But to incorrectly compare it to other languages, ignoring their pro's and even equalities with Java, that's just wrong.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PHP vs Java
 
Similar Threads
PHP & Kohana Framework
Please Advice
Building a website for college project
jsp, and php learning question
a very important question..