Live data from Hacker News

Ask HN: Why are there so few apps being built with JSP?

news.ycombinator.com

1–10 of 107 posts

Ask HN: Why are there so few apps being built with JSP?

#1
It seems to me that lots of small to medium webapps are built either in php or in ruby on rails. I'm wondering why there seem to be only a small minority of webapps (at least not enterprise ones) being built using JSP technology. Most articles and posts I see on HN seem to be webapps built with other technologies but Java.

JSP web apps can be built quickly as well. Eg. you have the JSTL tag library, and orm frameworks such as MyBatis or Hibernate. And there are also other things for simplifying, decoupling and modularizing a webapp like the Tiles framework, Struts, Spring MVC frameworks etc.

Now, I know for a fact that there are some other advantages php or rails apps have, particularly the lower price of hosting and possibly smaller memory requirements, but I'm wondering if there are any other reasons that JSP/Servlets/Java based small webapps are such a small minority and why adoption seems to be rather low for small to medium web 2.0 apps.

Re: Ask HN: Why are there so few apps being built with JSP?

#2
From what I've seen/heard, I think the lack of cheap hosting was one of the biggest things that kept Java from catching on as a preferred platform for the kinds of webapps that you see people building with PHP and/or RoR. That problem has, IMO, been mitigated somewhat by the emergence of cheap VPS providers... now hosting is hosting, and what you run on your server is entirely up to you. But by the time cheap VPS's became commonplace, it had become "cool" to hate Java. And, to be fair, there is a little more of a learning curve to get started with Java and most of the Java based webapp stacks, compared to, say, RoR or whatever.

Also, to be fair, other platforms have "caught up" to what were some of the early advantages of Java. For example, at one time I would have cited JMS and the easy accessibility of async messaging from Java as a big advantage. But now there are a bazillion messaging systems and most (if not all) of the major ones have easy to use client libraries in Perl, Python, Ruby, etc.

OTOH, Groovy/Grails brings a lot of the advantages of a RoR type framework to a JVM based ecosystem, as does Rails on JRuby, so more and more things are evolving to where the various platforms are approaching parity.

Re: Ask HN: Why are there so few apps being built with JSP?

#3
I can't speak for everyone but the reasoning behind my choice of php is 3 fold 1) Ease of set-up 2) I'm simply more comfortable with php 3) Better online resources / documentation

In the end it came down to picking a language I was comfortable in and could start moving forward the fastest with.

Re: Ask HN: Why are there so few apps being built with JSP?

#4
On the low end, I've always thought java has a significant disadvantage: memory footprint. In particular, this is compared to PHP/Perl/RoR/etc.

When you start your java app you pre-allocate all the memory you're going to need for the process' lifetime. This could be 512MB, this could be 2GB+, but it's never small. And this is unaffected by your initial traffic volume. It's the same for 0.001 hits/sec or 5 hits/sec.

On the other hand, if you drop a bunch of PHP scripts on a server, Apache only uses the memory it needs. Sure, you may have some pain scaling it later, but to get up and running you can get a cheap server and run your code.

Also, while I have your attention, have you ever tried installing an enterprise java webapp? It's not like you can pile a bunch of them into one JVM on a machine. I run confluence/jira/bamboo. Each has it's own requirements and basically need to run in their own tomcat servers tuned with their own settings. It's a huge PITA and eats up a ton of memory.

Re: Ask HN: Why are there so few apps being built with JSP?

#5
Just to set up one of the Java frameworks you list is already a lot of work and a lot of wrangling of XML.

Without frameworks, it is probably OK if you already have a working web.xml. I used to just copy my working web.xml and modify it. Good luck if you want to create a working web.xml from scratch, though. The specification for a proper web.xml is a PDF with several 100 pages (last time I looked, a couple of years ago), and to parse it you basically need a scanner for XML specification files in your brain.

That is only for creating the working web.xml. Specifications for JSP and JSTL are several hundred pages on top of that.

Re: Ask HN: Why are there so few apps being built with JSP?

#6
I can't speak for PHP but if you follow the usual Rails conventions for db structure, URL layouts, etc then it takes significantly less time to build (and maintain) a Rails site vs Java EE.

Simply collecting all of your Java libraries, frameworks, dependencies, etc and getting them running in your app server can take days. Minor changes like adding a db column can end up touching nearly every layer.

All these costs do have benefits. Java ORMs generate much more efficient queries than ActiveRecord, have more flexible querying, and better fit into existing schemas; JSP engines can render tens of thousands of pages per second; Java app servers are easily clustered; and much more. But most of that isn't something small or medium web apps use, so why pay the price?

Re: Ask HN: Why are there so few apps being built with JSP?

#7

On the low end, I've always thought java has a significant disadvantage: memory footprint. In particular, this is compared to PHP/Perl/RoR/etc. When you start your java app you pre-allocate all the memory you're going to need for the process' lifetime. This could be 512MB, this could be 2GB+, but it's never small. And this is unaffected by your initial traffic volume. It's the same for 0.001 hits/sec or 5 hits/sec. O…

Actually I am afraid to host a RoR app on my server, which runs several Java apps. I think the server has only 256MB of RAM (it is old, but cheap), or maybe 512 - not a lot, in any case.

I am much more worried about memory consumption of RoR. Never really launched it in production, but wasn't it the case that you have to load balance between several Mongrels, each consuming > 100MB of RAM?

Java is just unpleasant to use - other than that, it is very fast and memory consumption is ok.

Re: Ask HN: Why are there so few apps being built with JSP?

#8
I prefer scripting languages over a pure Java stack simply because I can reload the page and see what's happening with the new code. Yes, you can use JRebel, hook up a debugger and tweak settings to get some hot code replacement, but they've always failed me at one point or another, resulting in hours of fun. The compile-check-fix-compile cycle gets under my skin, especially when you're using frameworks and libraries that take a minute to bootstrap.

The JSTL is not a factor in speeding up development. A lot of people even prefer a Velocity or Freemarker template engine when they are using Java. And I've never worked with MyBatis but have done plenty of projects with Hibernate/JPA and let me tell you: I've often come at a point in a project where I was wondering how much time I had saved by not writing the easy SQL queries and how much time I had lost by trying to work around some random restriction in the Hibernate API. For all the "hate" Django's ORM gets, I've never run into the same obstacles.

With all that said, the Play! framework addresses a lot of these issues and is a lot more fun to work with.

Re: Ask HN: Why are there so few apps being built with JSP?

#9
post #6

I can't speak for PHP but if you follow the usual Rails conventions for db structure, URL layouts, etc then it takes significantly less time to build (and maintain) a Rails site vs Java EE. Simply collecting all of your Java libraries, frameworks, dependencies, etc and getting them running in your app server can take days. Minor changes like adding a db column can end up touching nearly every layer. All these costs d…

It doesn't take me days to get a Java web app up and running. It takes me minutes. In days, my Java web app is done.

I'm a senior engineer who codes for pleasure, so maybe I'm faster than average --- but if it's taking you days to get your libraries together and minor db changes touch every layer, you're doing something wrong.

Re: Ask HN: Why are there so few apps being built with JSP?

#10
post #5

Just to set up one of the Java frameworks you list is already a lot of work and a lot of wrangling of XML. Without frameworks, it is probably OK if you already have a working web.xml. I used to just copy my working web.xml and modify it. Good luck if you want to create a working web.xml from scratch, though. The specification for a proper web.xml is a PDF with several 100 pages (last time I looked, a couple of years…

This is one of the specific reasons the Stripes Framework (http://stripesframework.org/display/stripes/Home) was created. The idea behind it is that most Java frameworks require too much configuration and the start-up time (to get rolling with development) isn't short.

Stripes looks to solve both of these problems while making it (actually) fun to do Java development. There's extremely little XML config setup.

There's not a single person I know that's familiar with Struts (1 or 2) and/or Spring MVC (or any other Java framework for that matter) that's tried Stripes, learned it in a day or two, and not really liked it.

Daoud also has a great book, "Stripes: ...and Java Web Development Is Fun Again" that's a great resource for starting out. In addition, the Stripes community is small enough that you can access the code contributors on a daily basis through IRC or the mail lists.

With Stripes-Reload and Stripersist, you can get a CRUD app up and running in under a few minutes--I think that's on par with RoR, isn't it?

IMHO, it's worth looking at.

Post reply on HN