I think “why PHP over Java” has been already discussed in other questions, the question I have is:
What makes LAMP/WAMP stacks so cheap and abundant vs a Glassfish one? What are the prime factors behind this trend?
Also, Why has no java based light weight stack come up as a competitor?
5
The answer is fairly simple: free market economics. There are lots of people looking for cheap PHP hosting and not a lot of people looking for cheap Glassfish hosting. This means more people will be willing to go in to the cheap PHP hosting business(less risk, more reward) than the cheap glassfish hosting business. This creates what is known as a virtuous cycle for PHP, more hosts means less risk for trying PHP, means more people looking for PHP hosts, and around it goes.
2
Why are Java servers so scarce and costly?
A: Java servers are usually used by large enterprises, thus are more complex and expected to be more costly than relatively simple applications built with LAMP. Also, Java is not primary used for web application but for middleware.
Also, Why has no java based light weight stack come up as a competitor ?
A: There is Groovy language based on the Java platform (runs on JVM) and Grails a web framework. It is very easily to be learned by Java programmers and very productive.
1
What happens here is the natural lifecycle of programming languages. The languages are innovative and disruptive at the beginning, than they become mainstream and than they slowly fade out while new and better suited alternatives arise.
Java kind of disrupted C/C++, PHP with Apache &co. ate a big portion of Java’s market. But I personally think tha PHP is also over it’s peak and the new languages like Ruby with Rails, or the functional programming wave, are coming fast.
So, I see C/C++ and Java being on their ‘legacy’ or ‘phase out’ portion of their lifecycle when no more extraordinary new features are added but the old ones are very stable and widely used.
PHP may be only a little after it’s peak. It is still fast evolving, but the downward trend can already be observed.
6
Because there is a perception that JEE containers are more “complicated”, which implies more support calls and more admin training, which drives the prices up. So hosting a JSP-based site is more expensive, so more companies go with PHP. There are also a lot more ready-made tools and components for small business web sites (shopping carts, catalogs, etc) already written in PHP, so it’s easy (read: cheap) for small companies to pull together a PHP-based site that does what they need, even if it’s not as robust or scalable as a Java-based one.