aspose file tools*
The moose likes JSP and the fly likes PHP vs JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "PHP vs JSP" Watch "PHP vs JSP" New topic
Author

PHP vs JSP

Christian Ebage
Ranch Hand

Joined: Aug 29, 2002
Posts: 47
Hi,
could someone please tell me why a developer would prefer JSP to PHP or vice verser?
I would be very grateful, for I am finding it difficult to choose.
Regards,
Ebage
Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107
I'm not that familiar with PHP but can you use object oriented programming
in PHP? I don't think so.
If you are familiar with OO then use it. If you ain't.. then learn it.


SCJP2 , MCP( 70-229 ) , Preparing For SCWDC
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
PHP is like ASP and JSP used to be: a lot of spaghetticode with businesslogic mixed in with presentation code.
No support for any equivalent of Javabeans or ActiveX components, etc. etc.
Nice for quick prototyping (but why not use JSP for that...), invites to writing unmaintainable code making it useless for largescale projects unless you won't have to maintain them and be long gone by the time the pages need changing.


42
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
but why not use JSP for that

Because you need an app server for JSPs.
invites to writing unmaintainable code making it useless for largescale projects

Very true. And the answer to the question. It's been proven in several studies on this issue that PHP is better for smaller less scalable apps while Java is for more robust applications. Also, devlopment time is faster using PHP. Maintenance time is faster in Java in my opinion. Modules are being added to PHP every day it seems but for large scale robust and secure applications I'd go with Java. One analogy that amused me was that people had a tendency to use Java for everything, including small applications. The analogy compared this to driving an SUV to the convenience store. You get poor gas mileage and you could ride your bike, but its cooler to drive the Hummer.
Me personally, I don't think there is one true language to use. Just depends on the circumstance. But, point of fact, IT departments tend not to use two different technologies for Web development. Hence, for maintainability and scalability, Java seems to be a better choice. Also note that it seems that Java developers make more money (at least for now). =)


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Mathias Nilsson:
I'm not that familiar with PHP but can you use object oriented programming
in PHP? I don't think so.

Actually you can, and even more so with the upcomming PHP5.
Here is a discussion I started a while back along this same topic of PHP vs JSP. It has some good information.
[ February 24, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
Wow, after reading the discussion thread started by Gregg (follow the link in his post), I'm compelled to roll up my sleeves and dive into the fracas, though it appears the dust has already settled. Regardless, here is my story:
I've been involved in the same gig for little over a year -- coding for Uncle Sam and trying to maintain some sense of individualism in the cube farm (yes, I'm outfitted with the latest and greatest cube goodies from thinkGeek.com). Anyhow, during this period, I've been involved in two major, web-based projects, both of which relied on JSP technology. Knowing Java beforehand, I welcomed JSP with open arms. I won't venture to say, definitively, why they chose JSP, they simply told me to use it. However, at this point, after learning the technology, I can probably make an educated guess.
Most of us know the power of Java (parden the allusion to those cheesy tv ads) when it comes to developing OOP applications. I was pleasantly surprised when I found that I could harness much of this power in a web-based environment. From inheritence to polymorphism, all of the Big OOP principles came into play in these two projects, and I began to feel as though I were on an alien planet with an ACME Green-o-Matic that transformed the barren landscape into strawberry fields and deep blue skies. Yes, much of my previous web-programming was rather dull and barren, but JSP opened the door to a whole new world.
Using JavaBean techonology, I could populate the server with objects, watch them do exactly what I wanted them to do (well, after quite a bit of tweaking), and all the while maintain a good OOP design. When used in assocation with JavaBean technology, JSP easily lends itself to the MVC architecture.
Of course, it is VERY easy to write "bad" JSP code by simply dumping all of your logic into the JSP page, but this is more of a developer issue than anything else.
We used javadocs to document our code and found this to be an essential feature when handing over the application to our client, since our client would be maintaining the code. As was mentioned somewhere in Gregg's thread, the javadocs are a sort of "crown jewel", if you will, for code maintainers.
In summary, most all technologies (questionable for some M$ products) have their place, and certainly what you can do with one, you may very well be able to do with another. Perhaps what it comes down to is this (at least from a software development perspective)...get the job done, and get it done efficiently and to the satisfaction of the end user. My supervisor was happy and our client (a high profile military organization) was not only happy, but I believe we exceeded their expectations. And this was done with JSP.
And hence my plug for JSP comes to an end.
WS


for (int i = today; i < endOfTime; i++) { code(); }
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
The only thing I want to add is:
1) JSP is not a solution in and of itself(not a good one at least). JSP is only useful when used in conjunction with the rest of the J2EE stack. That said, J2EE addresses a much broader range of applications than PHP could ever hope to address. Therefore, the PHP vs. JSP argument is definitely like comparing apples to oranges or monkeys to cars.
2) One of the points most often brought up in defense of JSP/J2EE is scalability. J2EE scales... PHP doesn't. This is, quite frankly, bull@%&#. Good software scales and bad software doesn't. This is true regardless of the technology used. It is possible to write applications that scale tremendously well in PHP just as it is possible to write applications that scale abysmally in JSP/J2EE. For the enjoyment of all please take a look at this article from ONJava.com: The PHP Scalability Myth.
Does this mean I favor PHP over JSP/J2EE? No. I just don't like seeing the same flawed arguments repeated over and over again. Besides, the future according to JSR 223: Scripting Pages in Java Web Applications looks to hold a convergence of PHP and J2EE so that PHP can be used as the scripting language in place of JSP.
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
I fully support the notion that PHP is scalable. It may appear that I prefer JSP over PHP, but this is not the case. As Chris pointed out, JSP is not a solution in an of itself, and neither is any other language. It becomes more a question of, what will be the BEST choice for the application. What I have found with JSP, and why JSP may be chosen over another language in certain situations, is its inherit ability to be extensible. With the back-end support of a high level language such as Java, the ability to add features to a web application is a welcome addition to a developer's toolbox.
For example, we're planning to implement an instant messaging system in one of our web apps. With the support of the java.net.* package, the incorporation of such a feature should be relatively painless (I hope I didn't just jinx myself). In theory, the design is rather straightforward, and I'm predicting the code will be as well.
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
Please note that my opinions on PHP and scalability were based on hearsay. Good article....
Tonny Tssagovic
Ranch Hand

Joined: Dec 30, 2003
Posts: 226
I read that Php scale myth article sometime ago and really did not like it. As for Php scalability you can read One Year of PHP at Yahoo. The slides however don't really show us how Yahoo deals with such a big load
I think that Php would fit well in most WEB APPLICATIONs, but when u need some business stuff and GUI like clients, and need to deal with diferent clients (aka a loarge project) you probably need something like J2EE.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Tonny Tssagovic:
I think that Php would fit well in most WEB APPLICATIONs, but when u need some business stuff and GUI like clients, and need to deal with diferent clients (aka a loarge project) you probably need something like J2EE.

I absolutely agree. However, when someone brings up the ole PHP vs. JSP argument I feel that they are implicitly referring to Web Applications.
Christian Ebage
Ranch Hand

Joined: Aug 29, 2002
Posts: 47
Thank you all very much for the input. It was a very educative discussion.
Regards,
Ebage
Ben Dover
Ranch Hand

Joined: Jan 30, 2004
Posts: 91
Originally posted by Mathias Nilsson:
I'm not that familiar with PHP but can you use object oriented programming
in PHP? I don't think so.
If you are familiar with OO then use it. If you ain't.. then learn it.


Yes, PHP has OO constructs, classes, abstract classes, inheritence, and scope etc. It has good OO capability and I personally have used it to design small, modular web applications.
PHP5 is pending and has improved OO abilities including interfaces, implicit pass by reference, and namespaces, and a whole bunch of other goodies.
For small to medium sized web apps its not a bad choice, especially with such a large user base, and we are even seeing open source frameworks for PHP that allow you to separate funcitonality from presentation, and reuse common code. There are also lots of open source PHP applications you can download, configure and use if you don't want to build your own.
Of course, you can't beat J2EE for scalable, high performance, reliable, maintainable applications, and all the tools and libraries that come with it, but PHP is always improving, and becoming a lot more like Java.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Originally posted by Chris Mathews:
1) JSP is not a solution in and of itself(not a good one at least). JSP is only useful when used in conjunction with the rest of the J2EE stack. That said, J2EE addresses a much broader range of applications than PHP could ever hope to address. Therefore, the PHP vs. JSP argument is definitely like comparing apples to oranges or monkeys to cars.

Not true.
I've written standalone JSP applications that didn't use any of the rest of the J2EE platform.
I'm currently writing a massive application using only JSP and servlets, no EJB (which is what most people consider "real" J2EE) at all.
PHP compares with a JSP 1.0 application that doesn't use servlets or beans.
It's a mess to code and impossible to maintain in the long term.


2) One of the points most often brought up in defense of JSP/J2EE is scalability. J2EE scales... PHP doesn't. This is, quite frankly, bull@%&#. Good software scales and bad software doesn't. This is true regardless of the technology used. It is possible to write applications that scale tremendously well in PHP just as it is possible to write applications that scale abysmally in JSP/J2EE. For the enjoyment of all please take a look at this article from ONJava.com: The PHP Scalability Myth.


PHP is almost analogous with spaghetti code and mixing business and presentation logic.
As such it indeed doesn't scale well. Code reuse is also almost impossible.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PHP vs JSP