The Joel on Software Discussion Group (CLOSED)

A place to discuss Joel on Software. Now closed.

This community works best when people use their real names. Please register for a free account.

Other Groups:
Joel on Software
Business of Software
Design of Software (CLOSED)
.NET Questions (CLOSED)
TechInterview.org
CityDesk
FogBugz
Fog Creek Copilot


The Old Forum


Your hosts:
Albert D. Kallal
Li-Fan Chen
Stephen Jones

Java Servlets and PHP

How do you compare these two systems for web development?

What is your favorite and why?

Thanks.
MdP
Tuesday, April 03, 2007
 
 
Funny, I was thinking about writing something "The good side of the J2EE spec, java servlets".  I haven't used PHP, but java servlets at the their core are pretty simple.

For when the servlet is initialized, you implement the init method.
init(ServletConfig config)

For processing when the HTTP server encounters a GET or POST request from the client, you implement the following methods.
doGet(request, response);
doPost(request, response);

From the request object, you can manipulate sessions and cookies and such.  Also, if needed you can extract HTTP header information including things like the browser user-agent value. 

With the response object, that can be used to forward to another action, servlet, write out content to the web client or other such actions.

All in all, the servlet spec seems pretty easy to follow and complete.
Bot Berlin
Tuesday, April 03, 2007
 
 
"All in all, the servlet spec seems pretty easy to follow and complete."

Uh... the spec might be easy to follow and complete, but most of us use the *implementations*.  WebSphere, Tomcat, Resin, JBoss, etc all implement certain things just a bit differently.  Admittedly, it's not the primary/core stuff like getting the results of a POST, but its in the implementation of the business logic (eg. beans), logging, and configuration.

Combine this with the compile, build, deployment system which - although manages packages beautifully unlike PHP - is much longer.
KC Send private email
Tuesday, April 03, 2007
 
 
They'll both get the job done, one advantage (that they'll hate here on the boards) as with PHP you can contract/hire hobbyists amateurs to make the site for much less than Java coders.

Of course the code quality will suffer and you might have a hard time extending existing code into a larger app.  But there are good PHP developers, you just have to find them.

There are lots of great (free) online resources for PHP, great if the developer is "learning as they go".

PS: I've never used Java servlets, just PHP, but I tried to be as unbiased as possible in the above post.
TravisO Send private email
Tuesday, April 03, 2007
 
 
"WebSphere, Tomcat, Resin, JBoss, etc all implement certain things just a bit differently.  Admittedly, it's not the primary/core stuff like getting the results of a POST, but its in the implementation of the business logic (eg. beans), logging, and configuration."

Well JBoss is based on Tomcat, the servlet engine anyway.

Yea, I agree.  For example, Websphere adds all kind of stuff to how the configuration is handled and other stuff, WASReqURL for example, wtf?

But, if you don't get into complex configurations you dont have to worry.
Bot Berlin
Tuesday, April 03, 2007
 
 
"with PHP you can contract/hire hobbyists amateurs to make the site for much less than Java coders."

Yes, unfortunately, there are huge groups of developers (and even some projects) out there which have caused this to happen.  I've had the "opportunity" to meet a few developers of this caliber and some of them admitted to doing it on purpose to ensure that their customers would come back.  This still happens on the Java side of things, but more and more of the tools are enforcing a certain mindset/architecture which makes it more difficult.

Sure, you can make Hibernate do stupid things, but it takes a) more effort or b) a complete lack of understanding of db design...
KC Send private email
Tuesday, April 03, 2007
 
 
MdP > Java Servlets and PHP. How do you compare these two systems for web development?

Unless there's a reason for mentionning Java, the question should rather be: When developping a web application, would you rather use CGI such as PHP, or an application server using Java servlets, Python (Django, TurboGear, etc.), RoR, etc.

Actually, I'd be curious to hear about scalability and perforance between a PHP application developped with an MVC framework (CodeIgniter, CakePHP, etc.), and one developped using an application server.
ZeFred
Tuesday, April 03, 2007
 
 
ZeFred has good point.

I've worked as legacy maintainer of lots of PHP I never wrote. It can make you cry. 5000 line files without a function. No switches. Globals everywhere ... I'm calling them varnighmaires as everythihng is a global. But you can write good code in PHP that is easy to maintain and extend and perhaps with the platforms like Zend even quite fast. I've never worked on a site that got more than about 300K hits in a day though. I think things are relative.

2 of my cohorts develop stuff in the J2EE environment and I had to write a few jsp's for it. Wow .. what a nightmare. First ... no one could do a build. I could do a build then I could not and other developers never could. If you use your local box as dev box which java people do then be real careful about what you do. We had to use some lame IDE as well. The build process really took hours. One small change requires a complete new build. On our PHP sites a change takes 5 minutes (we have a push process to go from dev/stage/prod) but the J2EE takes DAYS as we have to request other people do it for us. One PHP guy found a way to compile his changes without having to compile everything but the other java developers would sit there and read a newspaper whenever they needed to compile something. Weird.

Anyhow, perhaps J2EE is good in reality and not just theory but even when a java guy we hired to maintain some java sites had a choice of writing an app in java or php, he chose php and he had just picked php up in a few weeks. BTW, his php code was much better than your normal php code though.
curdDeveloper
Wednesday, April 04, 2007
 
 
To ZeFred: little off on the definitions, there. PHP can be run as CGI, common gateway interface, where the PHP executable is called like a program in a shell.  But almost always PHP is running as a module/DLL, and not as a separate process.  That's where it gets a lot of its speed versus other scripting languages that tend to be run as CGI (of course there are some workaround that make "CGI" faster, just to complicate the issue).

MdP's question was about PHP and Java, not the various and sundry frameworks that run under either.  Those are important, and maybe that's a large part of what should be asked, but it's not his question.  Also, "application server" gets to be less clearly defined when PHP is part of the server as much as Java is part of Tomcat. (From the list you gave, it looks like any framework can transform a regular web server into an application server... and... why not? :) )
ABasketOfPups
Thursday, April 05, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz