tags:

views:

181

answers:

7

I am creating a web app that involves a lot of DB access and parsing and analysing data , Java is the language i am most comfortable with but recently have been told that I should consider to use PHP as it makes DB access protocols a lot simpler.

I dont have any great knowledge of PHP but would be willing to learn for use if it was going to be the better option as far as functionality , portability ect is concerned.

The Web app will run against an Oracle DB and use Flex for the GUI, Please any experiences of similar projects and what made your chosen approach better would help or just opinions of any sort.

Thanks Chris

+12  A: 

If you're comfortable with Java, I don't see the need to learn/use PHP. There is nothing that PHP can do that Java can't.

It's true that by and large, PHP is a much more permissive language, and some tasks can be fulfilled more quickly and with less code. PHP certainly has less built-in abstraction than Java has. But if you're comfortable with Java, I'd say stick with it.

(I'm saying this as a PHP developer.)

Pekka
You mean PHP scripter `:P`
jjnguy
+1. I'm a PHP dev, and a good friend of mine develops web apps with Java that are equally efficient.
Stephen
@jjnguy if there were a "middle finger" emoticon, I'd be using it right now ;)
Pekka
ha ha thanks guys , efficiency was a point I was worried about but that's reassuring . Thanks for your help
Chris
@Pekk, full disclosure: I'm a Java dev, and have never written a line of PHP. I just like continuing the stigma....
jjnguy
@jjnguy I figured as much :) Well, that stigma is something we'll have to live with... The "less bureaucracy" approach is why I love PHP, but there are numerous ways to build bad code with it.
Pekka
@Pekka, I had worked for around 7 web site in php and far more than that in java, I found Java a superset. :)
org.life.java
@org it undoubtedly is in many respects. It depends on what you want to build
Pekka
@Pekka , if you are equally fimilar with both of these for what kind of app you will go for PHP ?
org.life.java
@org I can't claim to be equally familiar with Java, not by a long shot. But from what I know, for anything that I want to be simple, portable and cheap to run / deploy and maintain, I will prefer well-written PHP any day. But this has been discussed numerous times on SO...
Pekka
@Pekka, agree, wanted your personal point of view :p
org.life.java
I see far more PHP engines on my shared hosting services than servlet containers. I will stick to PHP for small things.
whatnick
+4  A: 

IMHO if you know java, use JPA.

If you want to learn something new and fast prototyping, use python/django.

Paulo Scardine
Thanks Paulo il have a look at hibernate.
Chris
Replace the word Hibernate by JPA, as you should look at the API and not at one of the specific implementations.
Kdeveloper
@kdeveloper: done, thanks.
Paulo Scardine
A: 

Well, the real issue here is that you need libraries to make your work easier. JVM as a platform has many more options than PHP, if for no other reason than you can hybridize your application with embedded languages. Also, Hibernate is fantastic as an ORM (Object Relational Mapping), basically taking your tables and looking at them as POJOs.

If you're doing lots of 'raw' stuff, I actually like using Sequel, which is a Ruby library and works very well on JRuby. In general, I find that the duck-typing/concise code that people like about PHP is absolutely replicable in Ruby via JRuby (or Jython for you Python enthusiast types).

The best library is going to be dictated by the funkiness of the schema you're dealing with, in addition to the type of work you're doing. Do you need to do lots of complicated queries, fetching columns from several tables all at once? Or is it more along the lines of "I Need to fetch all the Orders for a certain customer and display it in an order history chart"? ORMs are better suited to the latter, which is what web apps tend to be, but your mention of parsing and analyzing makes me wonder if it's more the former.

Hibernate gives you the greatest flexibility, I find. It's not a good idea to use autogenerated stuff without reviewing it, but if you use Eclipse, there's a plugin that will generate the classes for you.

Another reason to go with Java: If you look at the Glassfish container for your web application, it has built in JDBC pools for you and you can look at the statistics and management of the pool. If you have a lot of database access, this could be pretty useful.

jcalvert
I find your assertion that "JVM as a platform has many more options than PHP" is absurd! I'd agree that J2EE, or J2ME, addresses a lot of areas that PHP doesn't, but not the JVM.
symcbean
The JVM has embedded languages. Are you telling me that the combined power of J2EE, Ruby, Python, Groovy, JavaScript, Scala and Clojure does NOT have more options than PHP?
jcalvert
A: 

I think there is no need for PHP , you can just go with Java.If you consider that application to be a web application then you can use PHP.So you can access it from anywhere

+1  A: 

PHP makes you do a lot of web things with less effort and fewer lines of code as Java does, I think (and I'm only talking about my own experience - there are always some who tell you "Use Java, PHP is crap" and there will be the ones to tell you "PHP is so much better than Java". Don't listen to us, simply try it or you will never know!). I do a lot of Java stuff, but as far as web apps are concerned, I'm not happy with it. For most of our customers, it's not possible to use Java, too, so I don't have that much of a choice, anyway.

There are some good PHP frameworks out there (Yii for example, which I like most) and really good orms as doctrine or active record. If you have to learn the language and are interested in agile development, also think about Ruby (Ruby on Rails) or Phython (Django) as these are the cool kids in town :)

Juri Keller
A: 

Why not use both? Quercus will run PHP in Java. You can call Java code as if it was native PHP functions. You get the best of both. And your PHP will actually run faster than under Apache.

I'm a PHP programmer, and while PHP DB access protocols may be "simpler" (debatable), I wouldn't say they are better. Java can use DB connection pooling and can "persist" data, code and objects.

Brent Baisley
You don't want to use both because you might not want to add risk and complexity to you're project if you don't need to.
Kdeveloper
+1  A: 

There is a huge amount of difference between the syntax, phuilosophy and implementation of the 2 languages. I would suggest that "makes DB access protocols a lot simpler" is not a particularly good reason in isolation for choosing one language over another.

My background is as a PHP programmer, but I currently support several large Java web applications. If you were starting from the same point with both languages then I'd definitely favour PHP over Java - but a full discussion of the reasons why would take a lot more time and space than are available here. However if you already have strong Java skills, then you have to weigh up the costs of acquiring the right level of skill in PHP - due to the differences in the way these systems work, you're going to find your knowledge of Java as much of a hindrance as a benefit in achieving proficiency in PHP.

Other factors I would suggest you have a look at are:

1) architecture - PHP requires far better understanding of the underlying protocols than Java (where a lot of functionality is provided by libs/ frameworks)

2) ease of deployment

3) performance considerations - using an opcode cache means the difference between simple programs written in Java and PHP is small, since the former are usually written inside very complex frameworks, PHP can often have the edge. It certainly does not have the same complexity for memory mngmnt

4) TCO - PHPs ease of use is a double edged sword - you need to know a lot about Java just to get a program running, but the world and his dog think they can write good code in PHP. IME its more difficult to find competent PHP programmers than Java programmers.

symcbean