Why isn't Java used for modern web application development?
As a professional Java programmer, I've been trying to understand - why the hate toward Java for modern web applications?
I've noticed a trend that out of modern day web startups, a relatively small percentage of them appears to be using Java (compared to Java's overall popularity). When I've asked a few about this, I've typically received a response like, "I hate Java with a passion." But no one really seems to be able to give a definitive answer.
I've also heard this same web startup community refer negatively to Java developers - more or less implying that they are slow, not creative, old.
As a result, I've spent time working to pick up Ruby/Rails, basically to find out what I'm missing. But I can't help thinking to myself, "I could do this much faster if I were using Java," primarily due to my relative experience levels.
But also because I haven't seen anything critical "missing" from Java, preventing me from building the same application.
Which brings me to my question(s):
Why is Java not being used in modern web applications?
Is it a weakness of the language?
Is it an unfair stereotype of Java because it's been around so long (it's been unfairly associated with its older technologies, and doesn't receive recognition for its "modern" capabilities)?
Is the negative stereotype of Java developers too strong? (Java is just no longer "cool")
Are applications written in other languages really faster to build, easier to maintain, and do they perform better?
Is Java only used by big companies who are too slow to adapt to a new language?
I think you're incorrect: it is still used, it's just lost cool factor.
@Graham Lee: Java has ever been cool? I must've missed something. Well, I guess it's cold coffee, but cool? I think the main reason is that java, especially the enterprise java frameworks have been and still are heavily overengineered. You can't consider them lightweight, you just use them because you need the distribution/balancing/scalability features of the platform and want to use a framework for the frontend that is done with java, too, for the sake of homogeneity.
Maybe, because it's not modern? :P And Java *never* was cool, simply because it threw the hacking part out of programming.
@Falcon, bac2dos, Java is a great language for what it does well (object-oriented application programming), but the web components of Java seemed a bit... hacked together without thought to how they were actually going to be used.
@Falcon Java was cool back when it was first introduced, Sun did a great job hyping Java, whether the hype was justified or not has nothing to do with it being cool or not, a lot of cool things are hyped for no reason.
Have a search for "Java web development" on this stackexchange site, there are plenty of similar questions, also with good answers.
@Falcon, you happen to be a .NET developer?
@Cliff, "hate" might be too strong a word.
@Thorbjørn Ravn Andersen: Yes, at the moment I primarily develop in C# for .NET. But I've coded my share in Java (especially Java EE) and I cannot say I miss it.
@Falcon, you should have a look at creating web applications with JSF 2.0 in Java EE 6 and compare it to your experiences. You may be pleasantly surprised.
I have a ton of experience coding Java, but I run my own website using PHP. Did it in part to "keep up", but also because it is easier to setup and get it going. Just less hassle. But there is a huge, huge downside to PHP (or at least my crude attempts at it): Messy code, little to no reuse, mix of HTML and code, nested includes, etc. Back when I first started with Java I was writing JSP pages the same way, messy, but quick and simple. For some stuff that works great. But it can get pretty ugly if you are not careful. I've seen lots of PHP frameworks that never cleaned themselves up.
I would use PHP for small-sized projects and Java for larger projects. I once started a project in PHP and then had to throw it away in favour of Java.
@back2dos: Are you serious? A language is not cool because you cannot hack with it? Do you have any idea how many hours of tedious debugging you can save by not being allowed to hack? Especially when working on a large project.
Java is indeed less popular on the webdev zone than ruby or PHP. Yet, the fact it is the main technology behind Google+ and LinkedIn, and plays great role in twitter, shows it is still used for "cool and massive" applications.
Some useful comments about this question over at Hacker News: http://news.ycombinator.com/item?id=4090298
@TzuryBarYochay I don’t think Java is used anywhere in Twitter, do you have a source for that? You may be thinking of Scala.
If you `haven't seen anything critical "missing" from Java`, you've probably fallen victim to The Blub Paradox.
@Falcon Agreed; JSF2 is a wasteland of bugs and pain and horror. Best thing I ever did was give up on it. I love much of JavaEE6 (JAX-RS, CDI, etc) now that it's had TWO YEARS to cook the worst of the bugs out, but JSF2 remains awful. I was getting short snatches of productive code writing done between reporting bugs when using JSF2.
@ThorbjørnRavnAndersen You *like* working with JSF2, RichFaces, and Seam 3? What about the bajillion bugs everywhere in the framework, the awful documentation, and the uninformative exception backtraces from hell?
I had a full 8 years with Java, and it was precisely the web stack that drove me away from the Java land; As a coder with 12 years of experience I realize Ruby on Rails has shortcomings (some of them nasty), but at least I can get the job done with it. And the Java web stack? I felt like I was walking through a mine field. With 10+ middle-to-big Java Web projects under my belt, I finally gave up and figured "there has to be a faster/easier way to do this!" And, there is -- and it's not only Rails. SIDE NOTE: Java by itself is a very nice language, but I had enough of its verbosity, for good.
@CraigRinger I believe there are some steps in-between "love" and "hate". Apparently you don't.
@KonradRudolph Scala indeed, which is a middle layer above the JVM -- Java Virtual Machine. This is Java by all means.
@TzuryBarYochay No. Details matter. The question was about Java, not the JVM. Not Clojure, not Scala. The reasons why Java falls out of fashion for (web) development are completely different (indeed, complementary to some degree) than for other languages targeting the JVM.
@ThorbjørnRavnAndersen Ouch - but fair. Call it "increasingly intense dislike". You're right that all frameworks have trade-offs and issues, and that it's a very complex job. I've suffered through a long jsf2 bug daisy chain as I foolishly adopted it when it was released and "ready", so I suspect I'm more bitter than is really healthy. It's not like Vaadin, play, or anything are exactly shiny perfectness either, just IMO a bit less broken and a bit better documented at the moment.
Relevant: Study of 49 programmers: static type system had no effect on development time... http://www.cs.washington.edu/education/courses/cse590n/10au/hanenberg-oopsla2010.pdf
@KonradRudolph "I don't think Java is used anywhere in Twitter" -- Twitter uses Java For their search engine, see http://engineering.twitter.com/2011/04/twitter-search-is-now-3x-faster_1656.html -- though this isn't a web app.
@Bozho They used an artificial language called Purity for that study. Allow me to doubt their results :)
Why people say Java/J2EE frameworks web app is more secured than other? Only because of Java uses sandbox security? or any other factors compare to other server-side technologies?
Sounds like everyone has a problem with spring framework and JSF. Use standard java + embedded tomcat (import a few jars as opposed to installation) -> problem solved. If your application takes too long to develop or is too complicated then the solution is simple: Learn Java and stop wasting your time on money-driven frameworks. There are ways to increase development time i.e. patterns, oo principles, increased programmer control & knowledge, etc. As for plumbing work, use online tools and regex replacers.
I think the issue here is that Java has been somewhat outgunned by other technologies when it comes down to creating strictly the UI part of the web-app. Doing it in JS, with some of the new frameworks (like Angular) is a lot simpler (and more natural) than doing it with Java EE's Web UI technologies (JSP, JSF, etc). On the server-side of a web app, Java still holds strong.
Modern day startups need to hit the market as soon as possible. They don't need to spend about six months in order to release their Java web application.
Twitter for example was built using Rails/Ruby but once it became unscalable, they migrated to the JVM.
Not to mention that the development process isn't productive: code -> compile -> deploy while it is in frameworks like (Rails/Django/Grails): run testing server -> code -> change things and see what happens.
The good news is that JRebel lets you see code changes instantly.
Play Framework is also like Ruby on Rails, but for Java. Code -> update your browser.
Just try to get rid of some misconceptions. Java EE is not the only thing on the Java server side as many seem to think.
Facebook also does something similar. Their code base is in PHP, but because of speed and scalability problems, they had to write a compiler (HipHop) that compiled the PHP to C++, which is then compiled using g++. It's funny how everybody talks about how great ruby and PHP are and that all the sites are built around them, but then when you look at how inefficient they are, most large organizations have to switch to something else. If I recall correctly, Craigs List hasa lot of backend code written in C/C++ for this very reason.
@jhocking Twitter didn't migrate to Java entirely. They are adopting the JVM. http://www.infoq.com/articles/twitter-java-use
@Kibbee: the problem is not necessarily the language, it's often the framework (particularly the ORM) that reduces performance. And, depending on the web server, it can be the way that you connect the module or interface to the web server's request pipeline as well (mod_python vs. uwsgi, for example). The inefficiencies are generally coming around the database and database interaction code for most companies, certainly not the web tier. However, at Facebook and Twitter's size, even slight web tier inefficiencies are worth thousands of dollars. Not so much for a startup.
1) Using Eclipse, compilation happens as you type and you will rarely notice. Also, running Tomcat within Eclipse I can restart an app in under a second. I'm rarely hindered by restarting my apps 2) There's no silver bullet, guys. Ruby or any language doesn't make you 10x faster. The problem with Java dev is often ramp up time, but if you know what you are doing, you can get working in a project in <10 min.
afair, Twitter is using Scala. It's JVM, but not Java, so the point is only halfway valid...
A big factor that many people who already know Java and Java EE neglect is the learning curve. It's monsterous. Some technologies like JAX-RS are easy to use once you "get" the stack, but there's a hell of a lot of stack to "get". Others, like JSF2, are killer learning brick walls from hell all by themselves, and badly documented too. See http://blog.ringerc.id.au/2010/08/im-not-smart-enough-to-use-java-ee.html and http://blog.ringerc.id.au/2010/08/java-ee-6-doesnt-just-work-in-even.html
@Jonas Not only is Java EE not the only option, but you can use just the good bits of Java EE 6 and avoid JSF2 and other problem areas. I'm loving Vaadin on JBoss AS 7 (an EE 6 server) with CDI, JAX-RS, and other JavaEE6 goodies. I sure hope you can use Play on an EE6 server the same way, 'cos I'm not going back to working without CDI.
@Jordan: `However, at Facebook and Twitter's size, even slight web tier inefficiencies are worth thousands of dollars` at the scale of Facebook and Twitter, thousands of dollars are worth a penny.
its pretty easy to get hot-deploy with Java and eclipse without using jrebel or similar http://stackoverflow.com/questions/998737/integrating-tomcat-and-eclipse-as-a-hot-deploy-environment
The development cycle is just like with a scripting language, you just have to turn one or two things on: http://techblog.bozho.net/?p=714
Java and any other static language, have two huge benefits, almost worry free refactoring, and API discovery without documentation.
Those aren't benefits. Those are things you feel you need because you're working with a clumsy, verbose, inflexible behemoth of a language whose only real selling points are all the problems it solves that it created in the first place. Only good architecture leads to worry free refactoring and in my experience, Java can be but almost 99% ain't where that's at. Also static is not a prereq for auto-complete. I don't know why people keep insisting on that.
>>Twitter for example was built using Rails/Ruby but once >>it became unscalable, they migrated to the JVM. What has scalability to do with language? It is the architecture that makes a platform / app scalable not the language. I am quite sure they would have switched to JVM for some other reasons.
Actually the way ruby (matz) threads or rather doesn't is a language thing. Memory management in Python make it harder to scale, and PHP also suffers memory issues. These are baked into the language, yes there are ways to work around them, but then are you really using the language any more, or just the syntax.