why not use a non compiled language like php?
Because you can’t write applications in PHP? (not counting tcl/tk sollutions)
Because Java is WAY faster than PHP because it’s compiled, not interpreted?
Compiled languages run faster than interpreted languages.
Basically there are four different levels with different advantages and disadvantages.
- Languages cuch as C++ are fully compiled in one go. That makes them as fast as possible but less portable.
- Languages such as Java compile to an intermediate code that is then interpreted. This makes it slightly slower but more portable.
- Languages such as PHP use a just in time compiler where the code is compiled each time just before running it. This makes it more flexible but slower.
aren’t there millions of php applications? offers.com is entirely made in php.
I should have been more clear. I meant actual desktop GUI applications. For example applications like NetBeans which is written in Java. I don’t see anyone writing an application like that in PHP.
But that might not answer your question, since it’s not webrelated.
For websites one might argue that java is a more stable/mature languages than PHP, in which you can write more robust code than in PHP. And as already been said it’s faster to booth.
Java is possibly the most popular choice for web development language amongst the medium to large companies (except for those who want nothing if it isn’t from Microsoft and whop therefore use .net). Few companies of that size would consider anything else (although Python appears to be growing in popularity since Google picked that as their development language of choice).
I don’t feel that compiling and/or speed has anything to do with why companies choose java.
If your application runs slow throw more hardware at the problem until it runs reasonably. If that doesn’t fix the problem then fix the slow code.
I feel that Java is used by large companies for several possible reasons:
- Java is a reasonable Object Oriented language that has a more then reasonable track record of being stable and robust.
- Java is quite secure. I haven’t read about many security holes in the main web containers for java (tomcat, jboss, resin, etc…) or the language itself. Of course that doesn’t mean that programmers don’t open up holes themselves by doing stupid things like using raw sql instead of using prepared statements, but that is a different topic.
- The base Java code is maintained by one company. I don’t know how php is maintained, but I thought it was done “by committee”.
- Java has several nice frameworks (spring and struts) that allow for reduced development time on web development that help program toward low coupling and high cohesion. These products are not easy to learn, but they do help with development over time.
- Java can be extremely unit testable. Are there even unit testing tools for php that are reasonable to work with?
- Java consultants tend to make more then php consultants. If you were to go into consulting which would you pick? More or less money?
The last point is hard to justify, but I do remember reading a blog post somewhere that made that argument and they defended it well. Which leads into the, not always true perception, that more expensive equals better product.
An alternative explanation I can see is the heavy use of contractors and/or combination deals with vendors. I know where I worked last year, the ECI/EDMS package they used was purchased by IBM. IBM HEAVILY, HEAVILY, HEAVILY pushed java as their development platform of choice, and their “certified” consultants do the same. Didn’t matter that the existing package was .net based and ran faster and more stably (sp?) due to the base file system interface provided in the CLR.
I agree w/ his points. Many times Java is chosen simply because they (I meant they as the person providing $$$) look at other successful project’s programming language. Certainly, PHP is a very good web capabilities. But, I’m not sure if I’ll use it for a site like Amazon. Anyways, my reason is simpler… $$$:cool:
BTW, I do feel that for non trivial applications, either a .net or java solution is far superior to a php solution because of the Object Oriented ability of the languages.
Being able to use objects and event driven behavior instead of procedural programming gives a huge advantage in the structure and flexibility of what a developer is able to accomplish.
Since PHP is just as much an object oriented language other languages you mention, your comment makes no sense whatever. Any object you can create in Java you can create in PHP and use exactly the same way, only the syntax differs slightly.
The only reason Java is more popular than PHP is that it has been around for longer and companies have no reason to swich between languages that have equivalent functionality because that would mean added expense to retrain all their staff.
I think it’s silly to say that’s the “only” reason. What you’re saying is PHP == Java. Sure both are OOP but what about third party support? I am pretty confident that there are at least 10x more COTS and open source framework in Java. This is why Java is still the King! Rarely, would you ever reinvent the wheel and there are many frameworks that are “well” matured and stable that’s ready to use. For example, in Java world we embrace a framework called “Spring”. Does PHP have something similar? I doubt it… Yes Java > PHP in every degree possible… fine~ call me a Java fanatic ^_^. Not saying that PHP is horrible language. I think it’s a very good language and much simpler to learn than Java. Then again the “true” quality of programming is not the programming language itself, it’s the programmer who created it.
If you truly think that Java is nothing but OO then you’re completely missing the “big” picture.
okay these points make a lot of sense.
one framework that comes to mind is the zend framework for php. after reading these replys, there are some valid points, but it seems as if php already has good alternatives to what java has…
-php unit testing
it almost seems like companies pick java out of preference.
One reason could be why companies stick with MS technology - “legacy”.
There’s usually a lot going on, website, email handling, database, intranet apps, all kinds of data proccessing going on and it all needs to be “transaction safe”.
Java has been around for a while and once a company gets “entrenched” it’s not likely it’s going to change too soon without sufficient bottom-line incentive.
That’s basically the point I was trying to make. Most of the companies using Java have been doing so since before PHP 1 existed.
As far as everything else is concerned there are pros and cons for each language that to a large extent cancel each other out if you are looking at things generally. If you start to look into more specific requirements one language may have an advantage over another but which it will be depends on your specific requirements.For smaller companies the choice is usually based on what their hosting provider already has available on the server.
I didn’t realize that php had objects and I take back my comment.
I doubt that this is the ‘only’ reason. Java can be used for web, desktop, and embedded apps. Java has some incredible libraries like hibernate and spring. And again, java is quite secure ‘out of the box’ (distance based on developer knowledge and ability varies). But, I’m sure with time, if not already, php will have very similar tools.
In the long run the difference will boil down to programming style and technique.
I like compiled languages that are strongly typed. Programming large applications is difficult and confusing and I find that those two attributes (compiled and strongly typed) help me minimize the confusion.
The real question should be, what madness would make someone choose PHP over any other option?
Java was presented to the world as the; " Write once run anywhere." language. The current rovers on Mars are using Java, so the “anywhere” part of that is interesting.
Java is also one of the languages of choice for mobiles because of that sentence above. In my opionion people use Java for what was mentioned before; portability.
This is probably the main reason I’d like to get back into java, years ago, I did servlets. I liked them, but they’re just too expensive in terms of hardware requirements and cheap-o servers. (my current production server is a PIII, running several other things)
PHP is less portable than assembler, at least with assembler, you had a common processor… in PHP every single host has a slightly different version of PHP, you’re forced to do stuff like:
SELECT foo from bar where id=$v;
(which is incredibly stupid)
Because in PHP, you may or may not have placeholders.
These kinds of things drive anyone who’s serious about software development out of their minds.
No one who knows PHP properly writes their SQL calls that way any more. They all use PDO or mysqli with prepare statements using placeholders. These ways have been around a long time and the last of the systems that didn’t support them disappeared years ago.