Live data from Hacker News

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

programmers.stackexchange.com

41–50 of 188 posts

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

#41
post #23
post #20

Earlier quoted context omitted.

> Part of it is a framework issue. Struts is horrible...absolutely, stunningly horrible. Your controller is an XML file (seriously). Freemarker (the main templating language) makes ColdFusion look awesome. Play is better, but it seems built for the way websites were created in mid-2000. JSON is still a second-class citizen. Static actions are a weird choice given IoC is achieved via DI in a static language. 99% of we…

My complaint isn't about client-side rendering. It's about _anything_ that involves getting in JSON or outputting JSON. It's essentially being able to easily bind json to objects on the way in, and being able to use respond_to and to_json on the way out.

You're stuck in 2007. People doing modern java use:

    @Path("/hello")
    @Produces(MediaType.APPLICATION_JSON)
    class HelloController {
      class Greeting {
        public Greeting(String name) {
          this.content = "Hello, " + name;
        }
        public final String content;
      }

      @GET
      public Greeting greet(@PathParam("name") String name) {
        return new Greeting(name);
      }
    }

    > curl http://localhost:8080/hello?name=me
    {"content": "Hello, me"}

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

#42
post #38
post #27

Earlier quoted context omitted.

I did look at 2.0 when it came out, and I'm under the impression that you still need to write a custom binder. Just now I tried to look it up, but the documentation points to: http://www.playframework.org/documentation/2.0/JavaJson which is a 404. I also don't see a nice way to respond with the appropriate format based on the accept-header...not that you can't write that yourself.

How did you get that link? Here is what I get when I browse documentation. http://www.playframework.org/documentation/2.0.1/JavaJsonReq...

http://www.playframework.org/documentation/2.0/JavaRouting

http://www.playframework.org/documentation/2.0/JavaXmlReques...

it's all over the place...search for "working with json" on those pages. Thanks for the correct link though.

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

#43
I spent three long years doing Big Freaking Enterprise Java web apps. You can certainly do modern web dev in a Java stack (we were Struts, Hibernate, Spring, and an internal framework). It just fought us every single step of the way, and every time we had to do something new (that couldn't be templates off of working code) they'd have to get one of our three best engineers to spend a week fighting the new library into submission. Sometimes the libraries won.

The easiest way I can describe it is that everything you like about e.g. Rails was designed as a specific dig against the Java stack. I am told Play is less painful.

On the plus side: Java devs are plentiful, the library support is worlds deeper than the ruby ecosystem (particular around enterprise-y needs), and it plays well with teams of dozens (which you will probably need). I honestly think "restricts your developers terribly" is not a bug for typical Java projects, since the outsourcing shops contributing lots of our code base would have been even more dangerous if the code didn't restrict what modules thy could break.

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

#44
post #37
post #16

Part of the answer is Java itself. It's verbose, static typed, and requires a lot of boilerplate code to do properly. The fact that classes are a compile-time concern, rather than a runtime concern, is just such a drag. You end up with interfaces you don't really need, only so that you can inject them into constructors so that your app is properly decoupled and testable. Part of it is a framework issue. Struts is hor…

why does a language designed around an OOP perspective need a lambda (which comes from a functional programming perspective)?

Because otherwise you get a bunch of

    new Callable() {
      @Override public call() {
        return 1;
      }
    }

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

#45
post #37
post #16

Part of the answer is Java itself. It's verbose, static typed, and requires a lot of boilerplate code to do properly. The fact that classes are a compile-time concern, rather than a runtime concern, is just such a drag. You end up with interfaces you don't really need, only so that you can inject them into constructors so that your app is properly decoupled and testable. Part of it is a framework issue. Struts is hor…

why does a language designed around an OOP perspective need a lambda (which comes from a functional programming perspective)?

Because it's more expressive and leads to less and more maintainable code?

Who cares about paradigm purity? Especially given on a language that's not totally pure already.

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

#46
post #27

Earlier quoted context omitted.

I think you need to reconsider your views regarding play. Version 2.0 has been a major improvement regarding a lot of issues. Asynchronous Requests are inbuilt as well as Websockets. (And Json serialization is as easy as Json.toJson()) I agree that static controllers are not always ideal considering that Java does not support inheritance of static methods, but the arguments of why static controllers are chosen can be…

I did look at 2.0 when it came out, and I'm under the impression that you still need to write a custom binder. Just now I tried to look it up, but the documentation points to: http://www.playframework.org/documentation/2.0/JavaJson which is a 404. I also don't see a nice way to respond with the appropriate format based on the accept-header...not that you can't write that yourself.

Here the version of the documentation from the git repository: https://github.com/playframework/Play20/wiki/Javajson

it states that the jackson library ( http://jackson.codehaus.org/ ) is included in the framework which allows for type safe json bindings

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

#47
post #37
post #16

Part of the answer is Java itself. It's verbose, static typed, and requires a lot of boilerplate code to do properly. The fact that classes are a compile-time concern, rather than a runtime concern, is just such a drag. You end up with interfaces you don't really need, only so that you can inject them into constructors so that your app is properly decoupled and testable. Part of it is a framework issue. Struts is hor…

why does a language designed around an OOP perspective need a lambda (which comes from a functional programming perspective)?

> why does a language designed around an OOP perspective need a lambda

Because only through lambdas can you actually do OOP: a core of OOP is to tell objects to do things. That you can do with lambdas, through customizing "the thing". Without lambdas, you are left with the requirement to painfully and painstakingly get bits and pieces in or out of objects in order to do the thing yourself, ending up with a horrendously procedural language with a smattering of objects added on top.

It's no secret — or mistake — that blocks are first-class components (and literals[0]) in the ur-OO language: http://en.wikipedia.org/wiki/Smalltalk#Code_blocks (as well as http://en.wikipedia.org/wiki/Self_(programming_language) )

[0] and really one of the few pieces of syntax

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

#48
post #14

> why the hate toward Java for modern web applications? Verbose language. But more importantly, needlessly verbose and badly designed apis. JSP: You have ${fn:size(emails.unread)} unread email(s)! You have no unread emails! Saner templates: You have ${emails.unread ?: 'no'} ${emails.unread?.pluralize('email')} ! http://paulbuchheit.blogspot.in/2007/05/amazingly-bad-apis.h... > But I can't help thinking to myself, "I…

"Saner templates: You have ${emails.unread ?: 'no'} ${emails.unread?.pluralize('email')} !"

At the cost of throwing internationalisation out of the window. At least the example you led with is more conducive to localisation.

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

#49
post #45
post #37

Earlier quoted context omitted.

why does a language designed around an OOP perspective need a lambda (which comes from a functional programming perspective)?

Because it's more expressive and leads to less and more maintainable code? Who cares about paradigm purity? Especially given on a language that's not totally pure already.

I don't care about paradigm purity, but given the amounts of java and lisp i've written, I didn't see why java would benefit from a lambda.

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

#50
post #37
post #16

Part of the answer is Java itself. It's verbose, static typed, and requires a lot of boilerplate code to do properly. The fact that classes are a compile-time concern, rather than a runtime concern, is just such a drag. You end up with interfaces you don't really need, only so that you can inject them into constructors so that your app is properly decoupled and testable. Part of it is a framework issue. Struts is hor…

why does a language designed around an OOP perspective need a lambda (which comes from a functional programming perspective)?

Because lambdas offload programmer work to compilers.

Think of a piece of code like:

  array = [1..10]
  evenNumbers = array.where(x => !(x % 2))
Now think of how to write that code not using lambdas.

In Java where people seem to like typing unnecessary stuff it would make sense to not have lambdas as then you can type extra stuff. Also lambdas would reduce KLOCs thus making teams using java with lambdas less productive.

This is similar to the reduced productivity seen by teams using scala or clojure on the JVM.

Also, OOP has nothing to do with procedural or functional languages, it's completely orthogonal.

Post reply on HN