Live data from Hacker News

Why isn't Java used for modern web application development?

programmers.stackexchange.com

91–100 of 188 posts

Re: Why isn't Java used for modern web application development?

#91

This is just my experience but if there has existed a common line of thinking with the rabid Java fans I've worked with, it would be closed mindedness to the point of being its own brand of Stockholm syndrome. The thinking that whatever the project at hand may be, a Java based solution is always the correct answer and there is nothing to learn from alternative platforms. I've heard "Why would anyone want to use anyth…

>>the rabid Java fans I've worked with [closed mindedness]

It is hard to argue against anecdotal evidence, but of the cases you mention -- java, Rails, Django -- imho, it is not exactly the Java people who seem to be the worst language/framework fanatics...

(That said, scripting languages eat static languages' lunch for development speed in most every case I've seen.)

Re: Why isn't Java used for modern web application development?

#93
post #90
post #33

I've been hacking Rails since 2004, and I've made the switch to Java (dropwizard+mustache) for basic web development this year (sometimes with a meteor-like micro-framework I rolled myself). Benefits: - Higher quality code. Java is easier to refactor than Ruby, which makes up for the lower language power. - Performance! - Actual concurrency! - Faster server spinup and incremental changes. Rails with 20 gems in develo…

> Higher quality code. Java is easier to refactor than Ruby, which makes up for the lower language power. Let me rephrase: "It's easier in Java to rename identifiers than ruby, because my IDE does it for me." Now that's fine, but I don't see how do you conclude: Easier to rename identifiers => Higher quality code. How on earth? Easier to rename identifiers => Makes up for lower language power. What language deficienc…

Your Java IDE also lets you move methods and fields, extract interfaces from concrete classes, push members up or down, find all references to a member (reliably), view inheritance relationships, and much more. And it can do all of those safely, warning you if you'll shadow another name. I wish I had that stuff in a Ruby IDE.

I've used Eclipse for a long time, but not for JEE projects, and I don't see any "stop the world" behavior when it's compiling Java. Java compile jobs run at a low priority and rarely block another workspace job. If you want to save a file that's being compiled, Eclipse will let you and restart the build. Maybe you mean "stop the world I'm launching a JEE app?"

Re: Why isn't Java used for modern web application development?

#94
I programmed java web apps for 10 years before I switched to python, 4+ years ago. I feel that I'm much more productive using python and can get much more done in a shorter period of time, and to be honest, I'm much happier when I develop in python. Here are some of the reasons why I think python is better then Java based on my personal experience, your milage may very.

Web Frameworks:

When I first start programming web apps in Java, Struts just came out, and it wasn't great, but it was the best thing available. I created a bunch of struts apps, and a few in other frameworks along the way. Whenever a new framework came out (Tapestry, Wicket, GWT, stripe, grails, AppFuse, Play, RichFaces, Spring, etc), I would try it out and see if it was any better, and most times it was only a little better, and sometimes not better at all. I do have to say the play framework is a step in the right direction.

Batteries not included:

One of the most annoying parts of Java was the fact that most of the libraries that you use were not included in java itself, you had to include a ton of 3rd party libs from places like apache commons. If you use something like hibernate with any other large library, you end up in Jar dependency hell, where hibernate needs one version of a jar, and something else needs another version. If you load the jar files in the wrong order, you are out of luck. You need to depend on tools like maven, and ivy to manage your dependencies, and this just brings in more dependencies into your project which results in projects being huge. I had some war files 100MB+ war files for the simplest web apps.

Too many options:

For some reason there seems to be way too many different ways to do the same thing in Java. There are over 38 different web frameworks for java according to wikipedia (http://en.wikipedia.org/wiki/Comparison_of_web_application_f...) and 23 different ORM's (http://en.wikipedia.org/wiki/List_of_object-relational_mappi...) just to name a couple of examples. If you look at other languages they have a more reasonable number. Some people think that having lots of options is a good thing, but it isn't it leads to a lot of wasted effort in the developer community, everyone is reinventing the same wheel, and if you are a new person to the language you have too many option to pick from.

App servers:

Java web applications are really heavy, and require a lot of resources to run. They are especially memory hungry. Like any piece of software they can be tuned to reduce their resource footprint, but compared to other languages their out of the box setup is horrible. In my past I have used weblogic, websphere, Jboss, tomcat, and jetty. I only used the first three when I was forced to use EJB's, but even if you aren't using EJB's they were large app servers and sometimes hard to configure and get running correctly. Tomcat and Jetty are much better and easier to setup, but are still resource hogs.

App Hosting:

If you aren't running your own server it is real hard to find shared hosting for your java apps at a reasonable price. The main reason is because java apps require much more memory compared to other languages, so it doesn't make sense for a shared hosting provider to spend their valuable RAM running a java site, when they could run 5 php sites in the same place. That means there are less providers offering java hosting, which in turn means higher costs to run your website.

Development Time:

When I developing in java, I found myself much slower then what I can do in python. I would need to make a change, compile, redeploy and then test, and this slows down the iterative process. I know there are ways to make this faster, but even at it's best, I felt much slower then what I can do in python.

There is also a lot less boilerplate code to do the same thing in python, so I spend less time developing the code as well.

Java just feels over engineered in a lot of parts, A lot of the API's and interfaces are just way to complicated for what you want to do. And everyone and their brother thinks they are a java architect and this results in big complicated systems that are hard to use and develop with.

IDE:

When I was developing in Java, I felt stuck to the IDE, I was lost without it. IntelliJ is the best IDE's on the market, and it was hard switching to python because there wasn't anything like it for python. So instead of an IDE, I just used textmate, which is just a normal text editor. It was hard at first, but because it was just a text editor, it was a really fast and responsive application. I could open my whole project in a few seconds, whereas when I want to open a project in an IDE it could take a minute or more, with a machine with a ton of RAM. The makers of IntelliJ came out with a python editor called pycharm, I bought it when it first came out, and it is great. But what I realized is that I don't need an IDE for python, I'm fine with a text editor. When I go back to working on Java web apps which I have to do from time to time, I try to use the text editor, but I haven't quite mastered that yet. I personally need the IDE for Java more because If I mess up something it takes longer to recompile and redeploy, which slows me down.

ORM:

When I first started using Hibernate as an IDE, I thought it was great, it had it's problems, and it wasn't perfect, but it was better then what I was doing before. I was happy with it, until I did an application with Django's ORM on a python project, and that opened up my eyes, that is how an ORM is suppose to work. After that project I went back to hibernate, and I just felt disappointed, and longed for going back to Django's ORM. Another great python ORM is sqlalchemy, which is similar to Django's ORM, but a little different. I have limited experience with ROR's ORM, but from what I remember, it was pretty good as well.

Templates:

The web templating systems in Java aren't that good, and I think I have tried them all (tiles, freemarker, velocity, etc). Most of them offer only basic functionality and are a pain to work with. On the Python side, my two favorites are Django templates and Jinja2, they have everything that I could need in a templating engine, and are really easy to use.

Re: Why isn't Java used for modern web application development?

#95
post #33

I've been hacking Rails since 2004, and I've made the switch to Java (dropwizard+mustache) for basic web development this year (sometimes with a meteor-like micro-framework I rolled myself). Benefits: - Higher quality code. Java is easier to refactor than Ruby, which makes up for the lower language power. - Performance! - Actual concurrency! - Faster server spinup and incremental changes. Rails with 20 gems in develo…

Is Rails that slow? There's absolutely nothing on my machine slower to start up that the jvm.

The JVM is very fast to start on my machines. For Java 7 on Linux x86_64:

  t:~% time java HelloWorld
  Hello from Java!
  java HelloWorld  0.04s user 0.02s system 94% cpu 0.063 total
It's not as fast as C or Ruby, but who cares about .063 seconds spent once at start-up?

  t:~% time ./hello 
  Hello from C!
  ./hello  0.00s user 0.00s system 0% cpu 0.002 total
  t:~% time ruby hello.rb
  Hello from Ruby!
  ruby hello.rb  0.00s user 0.00s system 86% cpu 0.009 total

Re: Why isn't Java used for modern web application development?

#96
post #90
post #33

I've been hacking Rails since 2004, and I've made the switch to Java (dropwizard+mustache) for basic web development this year (sometimes with a meteor-like micro-framework I rolled myself). Benefits: - Higher quality code. Java is easier to refactor than Ruby, which makes up for the lower language power. - Performance! - Actual concurrency! - Faster server spinup and incremental changes. Rails with 20 gems in develo…

> Higher quality code. Java is easier to refactor than Ruby, which makes up for the lower language power. Let me rephrase: "It's easier in Java to rename identifiers than ruby, because my IDE does it for me." Now that's fine, but I don't see how do you conclude: Easier to rename identifiers => Higher quality code. How on earth? Easier to rename identifiers => Makes up for lower language power. What language deficienc…

''Am curious. Where in basic web development does concurrency help? As far as servers go, evented servers(thin, mongrel) will perform as good as, if not better, than a threaded server. And evented servers can handle much more concurrent requests than threaded servers.''

I don't know what is 'basic web development', but the argument 'why do we need concurrency if I rarely use it' doesn't work. I mean if you are a front-end developer/designer and mess with CSS/JS/HTML all day (without format CS education), you are probably wondering why concurrency even exists, but in real-world programming you can't go far without it.

Re: Why isn't Java used for modern web application development?

#97
post #32

imho, Java is a great tool when it is deployed for its original goal: Platform independent GUI clients. Unfortunate its now mainly used on the server side, where it fits badly. The main reason I'm not using Java on server side is memory footprint. A typical Lighttpd, fastcgi, Rails, MySQL stack runs well within 256mb of memory on a Xen instance. A typical Apache, Tomcat, JBoss, Hybernate, Spring, Oracle stack require…

Users generally dislike java on the client side because the widgets don't integrate with their platform quite right. Java apps don't "feel right". A good web app is generally easier and cheaper to build and better than a bad GUI app.

I think the server is where Java shines. Good Java is almost as fast as good C (if it's not, you're using bloaty libraries or being cavalier with memory), and when something breaks you get a stack trace that a support team can make some sense of, and the build/dependency system is a lot nicer.

Sun sold Java as a plug-together ecosystems. They encouraged a mindset of putting together big teams of developers who live in padded IDEs and lean on bloaty frameworks, and not to think about resource usage. This won a mental traction with companies who wanted to believe that software work and developers should be a commodity, but has lead to a lot of bad systems. The results cause people to have some strange ideas about Java, like that it's slow.

The Java world places a lot of emphasis on inheritance, which may be an anti-feature. Before I became fluent with python I used to create thick abstract class hierarchies that aimed for perfection and reuse. In truth the result was a bloaty, brittle mess. Python's awful inheritance model forced me to learn how to think in ways other than inheritance.

Your example technology stack isn't a like-for-like criticism. You're criticising Java because Oracle takes up stack of memory and because you'd choose to use hybernate and spring. Why can't you use lighttpd, fastcgi, Java and mysql? The rails ORM isn't sophisticated, and it'd only be a couple of days' work to hack something up equivalent in Java. The result will be faster than rails and less memory intensive.

You missed the obvious advantage of rails over java for web development - a lot of web development involves heavy string processing, and the tools you get in ruby/python style languages for list processing and string manipulation are a luxury compared to what you get in Java! That was the main reason I moved away from Java for web work. With Java you try to build things to be configurable. You might need to do a different option later, and you know that it will be a laborious refactor. Whereas with scripting languages, the configuration language and the programming language are the same thing. So you just write the thing to do what you need it to do. And if you needs change a bit later, you throw away what you had without it feeling like the death of a child and then do the new thing and get on with your life.

Re: Why isn't Java used for modern web application development?

#98
post #52

Earlier quoted context omitted.

I'm not sure if you are being sarcastic, but you do realize that's a lot of code for something so simple, right? get '/hello/:name' do content_type :json {:content => "Hello, #{params[:name]}"}.to_json end

I think you mean "characters". Rather than code. "public static void main()" isn't a lot of code. It's three keywords, and one identifier. You may consider it a lot of characters, but it's pretty rare that a programmers bottleneck is speed of typing. I wish people would stop confusing "number of characters" with "amount of code". And FWIW, I find your example far harder to decipher. I have to know what => means, # me…

The last part of your comment is just language bias. symbols and hashes are fundamental to ruby. Why would I use string concatenation like my parent, when the language support string interpolation. It's as unclear to you as generics or annotations might be to someone who didn't know Java. Surely you see that?

I think you are being pedantic about characters vs code. But, for what it's worth, I disagree. You are having to create 2 classes, define a field, a constructor and use four framework specific annotation. I consider all of that code (made up of characters).

Both versions should be unit tested. The unit test might be more important in the Ruby version, but so too will it be easier to write.

Re: Why isn't Java used for modern web application development?

#99
post #52

Earlier quoted context omitted.

I'm not sure if you are being sarcastic, but you do realize that's a lot of code for something so simple, right? get '/hello/:name' do content_type :json {:content => "Hello, #{params[:name]}"}.to_json end

I'm not sure if you are being sarcastic, but you do realize that your version is entirely static while the other one is ready for future evolutions? By changing a single line, the java version can also produce XML or text response. By changing two lines, it can also respond to POST requests. And that's just the top of the iceberg. Oh, and in the ends, it's way faster than Node, Ruby, Python and most of the dynamic la…

And when those changes are made, I can change my version to:

   response = {:content => "Hello, #{params[:name]}"}
   respond_to do |wants|
      wants.json { response.to_json } 
      wants.xml { response.to_xml }
   end

Re: Why isn't Java used for modern web application development?

#100
post #67

Earlier quoted context omitted.

> So basically, it's due to lazy programmers who moan if they have to type or think too hard. Typing is a problem. Thinking too hard? Where does the OP imply he is averse to thinking? Being turned off that "fucking XML files are controllers" is being averse to thinking? > Also very very much fashion lead by hipsters who must be using the newest coolest untested thing on the planet. And those untested things would be?…

> "fucking XML files are controllers" XML has absolutely nothing whatsoever to do with Java the language. Some frameworks might use XML. There might be some built in functions/objects that deal with XML. But that doesn't mean you have to use XML. I certainly haven't in the 12 years I've been using Java.

The OP asked why Java isn't used for the web. One of the more popular Java web frameworks heavily relies on XML. It has nothing to do with Java, but it has everything to do with what the OP asked about.
Post reply on HN