开发者

Java OR PHP Server Side Web App and Why? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

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 开发者_StackOverflow中文版of similar projects and what made your chosen approach better would help or just opinions of any sort.


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.)


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.


IMHO if you know java, use JPA.

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


For me this comes down to performance. When you look at PHP it has certainly been deployed on extremely large platforms (Facebook used it almost exclusively at the beginning), but in general it is used on smaller platforms. Java, for me, when you look at it's scalability benefits is superior, but only when you know you're going to be scaling.

Understanding the underlying life cycle of a request is very important. That is, knowing what a Java container is and how a Tomcat server runs helped me understand tremendously the performance implications.

Don't try to choose one over the other over single attributes such as "ease of coding" or "database connectivity"- they are different enough that by focusing on just a couple of "important" things you'll be essentially selecting based off of biased information. That is, PHP makes it easier to connect to a DB if you look at them on a surface level- "Ugh! I have to install a JDBC, wtf is that???", etc- but that's the lazy man's excuse. There is nothing Java can't do that PHP can (that I'm aware of).

For me the question is how do you realistically (Read: realistically) see your application working- do you plan on getting thousands of visits per hour or are you talking a hundred hits a day like the grand majority of the little projects out there?

The benefits of PHP on smaller projects, particularly for the programmer that doesn't fully grasp OOP architecture are enormous- but don't get lazy and just take PHP because it's easier out of the box. Java is extremely powerful and simply by learning it can teach you more than you realized you didn't know about OOP and good programming practices in general (if you come from the self-taught realm like I do).

Basically, I'd say analyze your estimated project load plus ramp-up time if you have to learn one or the other, gauge your efficiency and scalability requirements, keep asking questions, and then decide which platform is better.

Hope that helps....!


PHP lets you do a lot of web things with less effort and fewer lines of code than 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 Python (Django) as these are the cool kids in town :)


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜