 |
Java versus PHP
Posted by bnewport on June 28, 2006 at 11:47 AM | Comments (8)
We started building http://www.trackpedia.com at the beginning of January this year. We initially knocked it together using mediawiki and vbulletin. It was very easy to do this. We had to do a little patching to make mediawiki use vbulletin for users and then add some extensions to mediawiki for googlemaps and some other stuff but overall very easy.
Hosting it was a piece of cake and we pay under 10 bucks a month for this. Performance wise, it looks fine. A lot of mysql statements generate each page but it's plenty fast enough.
If I had to do it in Java then I've a feeling, things would be more difficult. First, cheap hosting is hard although that seems to be getting better but there still isn't the competitive marketplace as their is in PHP land to really drive down cost.
According to the stats on our site, we are allocated 40MB of memory tops. It's piddly compared with what you're typical J2EE app takes. For hosters this must be a big advantage.
Then there is the fact that it launches a PHP interpreter for every page request and this isn't so expensive. If I tried to launch a JSP interpreter well, we'd be looking at 30 second response times easy.
I've had problems with JVM start up times before when using JMX with WebSphere. We provide a way for an external cluster infrastructure to push activate/deactive resource events using JMX to a WebSphere JVM. This lets them use our hot recovery stuff in 6.0. Unfortunately, it takes over a minute and a ton of CPU just to start a JVM with jython and a JMX client to send this simple command. 60 seconds is a long time. We ended up using a servlet as a script target and then use curl or a similar utility to send a HTTP request with the command to the servlet. Much, much faster and this is what we recommend right now.
I guess PHP has the advantage that it's just a text file where as most Java classes have extensive dependency requirements and drag in a lot of classes which slows down execution. None of that in PHP. It's just a simpler environment and for stuff like this, simpler seems better.
Developing with PHP is pretty easy. I don't miss not having an IDE, I don't miss have eclipse projects or ANT/Maven. I just point an ftp client at the server and edit with wordpad. Really easy. Edit/debug cycle is basically how fast your network is. It's pretty cool. Granted, it's just a web site but still, it works and it's fast and I could probably do this on a slow laptop with 256M of memory.
We need to figure out how to start making Java this productive for simple applications. A lot to learn here.
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
We creating a CMS system called OpenEdit that is file based like PHP but faster and with lower memory.
See how fast it runs one of our client web sites: http://www.maxoncorp.com
try it: http://demo.openedit.org/acme/
I added a $10 a month hosting plan: http://www.openeditgroup.com
Posted by: cburkey on June 28, 2006 at 12:59 PM
-
JSP interpreter? Your JSP can be precompiled as a servlet. You can avoid any initial compilation time by precompiling. No new interpreter is needed when a user accesses your page. Your page would exist as a servlet that spits out web content.
I have to believe you're seeing an environment problem if you have such large delay times. But even if this is an env problem, your point is reinforced...maybe it's overly complex to create a Java solution on the server.
Posted by: joconner on June 28, 2006 at 04:22 PM
-
The problem isn't Java. It's that there is no simple plugin for Apache (or I guess IIS...) that works like how mod_php works. If we had a mod_java and a mod_jsp that worked, then Java Servlet/JSP hosting would be simplified to the same level as PHP is. I say this as I run an ISP and am a J2EE (and former PHP) developer. mod_jk is a pain to say the least.
The good news is that Glassfish has made life much easier for deploying J2EE sites. We just need a simplified ISP centric mod_glassfish module!
Posted by: tegbains on June 29, 2006 at 12:27 AM
-
mod_gcj is what you're lookling for. http://mod-gcj.sourceforge.net/about.html
Posted by: robilad on June 29, 2006 at 05:02 AM
-
Hmm... well, probably Java won't be ever so fast to deploy as PHP for small sites (I think we're discussing only about this, as for medium or large stuff it's clear that Java scales while other technologies don't).
But is PHP as secure as Java is? I used to run my own sites upon a PHP product until last december. Yeah, it was easy to maintain (but as I didn't want to learn PHP it wasn't so easy to integrate with other stuff). Then it happened that I was attacked (of course while I was on a business trip) and the exploitation was based on the old trick of creating a malicious URL and gaining access to the file system. Still this old trick in 2006. The effect of the attack was reduced because I was pretty picky on security on my server, and it turned out to be mostly a DoS. But it happened.
I've switched to InfoGlue, a Java-based CMS. It works quite well, it runs under Tomcat, I had no problems at all with Apache integration, is secure and I enjoyed being able to write customized components in Java and JSP. The overhead with respect to PHP exists, but is small. I will never touch PHP any longer.
Posted by: fabriziogiudici on June 29, 2006 at 06:13 AM
-
JSP is reloadable. I have my tomcat web.xml set for "edit-refresh" development. Sounds like you were a little too comfortable with a slower development paradigm...
In terms of MediaWiki and Vbulletin, those are excellent established products, and would be harder to replace.
JForum http://www.jforum.net/ is an excellent forum for Java apps that definitely competes, but MediaWiki doesn't seem to have a comparable product in the Java space that is free to use. Confluence of course is out there, but requires licensing for commercial products.
Posted by: ilazarte on June 29, 2006 at 06:37 AM
-
Take a look at seaside at http://www.seaside.st for another paradigm shifting web development experience. Not sure about scaling but it definitely eases development, take a look at halos etc.
and its developed in Smalltalk, http://www.goodstart.com
Posted by: snoobab on June 29, 2006 at 07:55 AM
-
Sometimes simple is better. To build some wooden stairs that go less than a meter high from your doorwall to your lawn, you can use a handsaw, nails, and hammer. Heck, you could even get away with not using a ruler. Little jobs can use little tools.
However, if you were maintaining a giant wooden rollercoaster at a theme park, would you only want to use nails, a hammer, and a hand powered saw? No.
PHP has it's place. Quick, dirty, fast. Java has it's place. Easier to maintain. No spaghetti code. Scaleable. Extendable.
Comparing PHP to Java is like trying to compare a Microsoft Access to an Oracle. The two databases are are both tools that can be used to solve problems; Microsoft Access works well for small databases, and Oracle works well for large databases.
I would fear that any Java implmentation / clone of PHP would resemble what Microsoft tried to do with VBScript. Heck with the open sourcing of Java you might see something like this without Sun's initiative...
Posted by: phlogistic on June 29, 2006 at 05:38 PM
|