• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

on the server side - why Java vs say PHP?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jay,
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic