aspose file tools
The moose likes Jobs Discussion and the fly likes on the server side - why Java vs say PHP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Careers » Jobs Discussion
Bookmark "on the server side - why Java vs say PHP?" Watch "on the server side - why Java vs say PHP?" New topic

on the server side - why Java vs say PHP?

Jay Pennington

Joined: Jan 27, 2011
Posts: 5
I am a career software person but just now getting into Java. I started in the late 70's so I do understand about compiled languages, machine code, speed..etc.
Some of the books I purchased for beginners ended up being client side applet development...but I do write in JavaScript ...not the same but still both client side. I write a LOT of PHP with MySQL but I hear that everyone is looking for Java programmers - so I'm assuming they are looking for Java server side programmers? I know about the portablility of Java but what is the main draw when they say that companies are looking for Java programmers....and are they typically looking for server side Java programmers? And can you do pretty much everything in a server side Java program that you can do in PHP? Thank you! Your help in these questions will really help me get a better footing on what directions I need to go. Jay P.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31668

Welcome to CodeRanch!

Java positions can be client side or server side. Server side is more common, but they are not all jobs. You can tell which they want by seeing what other technologies they list in the position description.

You can do everything that I know of in Java that you can in PHP. My PHP experience consists of reading a few books though so I can't say for sure. java is a lot more powerful though and has concepts PHP doesn't have.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Chris Brind

Joined: Apr 23, 2011
Posts: 1
Hi Jay,

I'm in a similar situation. I've just taken on the team lead role with a company who's primary tech is PHP after coming from a Java background of 11+ years.

I'm working on a brand new product for the company. All the existing code is based on old versions of PHP so they have not been able to get leverage from any of the many modern PHP libraries out there. Anyway, my project doesn't have that restriction so I've been looking at using things like Doctrine, which provides Hibernate style ORM, annotations and other cool stuff, that would be pretty bog-standard fare in Java-land.

I've been trying to build a list of differences between Java and PHP. So far, in terms of how OO is implemented PHP is pretty close to Java. It only seems to be missing nested classes and anonymous inner classes, but of course it has functions and closures, so that mitigates the usefulness of having nested/anonymous inner classes to some degree.

The one thing that is annoying me though, is lack of static typing. Take these PHP classes:

You have no idea what types engineer and reporter are, though you can probably have a good guess from the classes I've listed what they might be, but if there were 100s of clases in your project ... well it gets a lot harder a lot more quickly. However, you can get around this to some extent by using static typing on setters:

But that's still not great. Also - that with PHP you're syntax isn't checked until runtime (that's mitigated by having a good IDE, I'm currently using Zend Studio, and unit tests for everything!).

Sometimes I feel like going to my boss and asking to use Java. Once he'd finishing throwing footballs and other office toys at my head I'm sure he would say no for a number of reasons:

0) "We're PHP" (I could mitigate this by saying that the developers are all experienced with OO and could pick up Java quickly enough, I suppose)
1) There is some level of re-use that we can get from our existing codebase (this is true as my project does share some concepts with the existing code)
2) PHP is much easier to manage on the infrastructure than Java

What he would mean by #2 is that in Java-server-land, you have to make careful architectural decisions about vertical scaling (making better use of existing hardware, multiple VMs, etc) and horizontal scaling (adding new hardware). In PHP land vertical scaling is pretty much there for free, then all you have to worry about is horizontal scaling. Then at a software level, in Java land you worry about which VM to use, which server you're going to use and all that, but in PHP land it's just Apache and PHP (though yes, there are commercial options, like Zend).

In terms of process we use TDD via PHPUnit and have continuous integration with Cruise Control, SCM by SVN (though I am considering GIT) and so on, so very little difference there.

There was something else that I discovered was not possible to do with PHP that is possible with Java, but can't remember just now what it is. I'll update this thread if it comes back to me.

Anyway... both have their pros and cons, and you're not the only one out there wondering why one or the other from time to time.

Have you tried LearnNowOnline?
subject: on the server side - why Java vs say PHP?