Why is it hard to find a place to host Java based web applications?

Date: Mon Dec 23 2013 Building Web Sites
I love Java. Lots. It's the neatest programming language I've used over the past 30 years, bar none.

However ...

You'll notice this web site is based on drupal. If I love Java so much, why don't I use a Java equivalent? And, as noted on these two blog postings, why are the PHP based web applications so much more popular than the Java equivalents?

They offer some interesting ideas, but let me offer my observation.

First, Eric Burke is close to this observation. He says Java hosting is expensive. However, I believe that's only part of the point. Why is Java hosting expensive? Now, that's an interesting question.

In his posting he thinks Java is more expensive for a hosting provider because it is "stateful". Okay, hmm, I think he's using that word differently from most computer scientists. An appserver is stateless, with each request being independant from the other. However he claims it's stateful because the JVM stays loaded. Well, gosh, PHP also stays loaded in memory, however it's buried as a shared library inside the apache instance and you can't see the memory PHP is taking up because it's glommed with apache. The Java integration with Apache, on the other hand, involves keeping the Java appserver as a separate process from apache, hence the appserver (tomcat usually) is very visible.

Why I think Java web hosting is rare, hence expensive, is the difficulty of setting up the connection between apache and the appserver (e.g. tomcat). It's somewhere around trivial to configure PHP to run inside apache, but to do so with Java is somewhere around rocket science.

The feasibility for a hosting company to be able to host PHP is much higher than it is to host Java. For example the Linux distributions usually come with PHP and apache preconfigured with each other, but not so with Java. If the hosting company is to set it up themselves, they're gonna have to hire some smart talent to jump the hoops of setting up mod_jk or equivalent connector to get apache and tomcat (or other appserver) integrated. Not all of the thousands of hosting providers are up to snuff with that.

Oh, and there's another reason Seven General Ruminations is using drupal. I did a search of a bunch of content management systems, including the ones implemented in Java. Drupal won on features. I think the popularity of PHP lends the market to supporting more PHP programmers than Java programmers, especially for the low end systems that support a web site the size and popularity of this one. This is evidenced by there being lots more content management systems written in PHP than in Java.

However, if I were to judge it on code quality I might steer far from Drupal. While Drupal has some interesting tweaks to its implementation, and they've done a rather good job of modularizing the system, it's far from pretty. The modularity is done by working past PHP's limitations rather than using language features PHP might offer. Note, Drupal probably predates the addition of object oriented programming to PHP, though the OOP in PHP is pretty lame anyway.