Live data from Hacker News

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

programmers.stackexchange.com

21–30 of 188 posts

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

#22
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…

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 found here: http://stackoverflow.com/a/5193721/616974

Still I think that developing with the play framework is a very productive process and can be compared with the likes of ror/django etc with the benefits of type safety all the way (including the templates)

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

#23
post #20
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…

> 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.

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

#24

Many Google services are backed by Java on the backend, and Closure compiled JS or GWT on the frontend.

To flesh this out a little more:

The question should be "Why isn't Java used by startups or for small projects?". Java certainly used for "modern Web apps" at more established companies. The issue is one of speed vs scale. Startups need to get to minimum viable product. They are usually small teams of 1-3 engineers, and value iteration speed over performance or maintainability. Running up against scalability issues or team code code maintenance issues is a problem "you'd like to have", that is, by the time you reach that stage, it's a sign your initial implementation helped you over the initial hump of getting customers or investment. You can afford to rewrite the app at that point.

A company like Google can afford the luxury of building things for scale up front, even though they may be wasting their time implementing scaling for something that might get no users, because they can absorb the loss.

At least, that's my opinion, that many many "cool", "hip", "modern" companies build small apps with small teams where iteration speed and simplicity are the greatest requirements.

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

#25
post #3
post #2

I think because of it's age, the pitfalls and limitations of the language may be more well understood, so it may suffer from a sort of 'grass is greener' effect.

Its age relative to what? Python is older by any measure, and the first public release of Ruby was only 7 months after Java's. Java certainly had a higher profile than either at the time, but they're all from essentially the same period. http://en.wikipedia.org/wiki/Java_%28software_platform%29#Hi... http://en.wikipedia.org/wiki/Ruby_%28programming_language%29... http://en.wikipedia.org/wiki/History_of_Python

Age in the spotlight doing web development.

Not age since the development of the language.

Mid-nineties it was CGI and mostly Perl.

Then Perl started to fade, and in the late nineties, early '00s, it was all Java and PHP.

Then Ruby/Python etc co started to catch on in the mid-00's.

And already Ruby and RoR is considered "passe" and old, and fadsters turn to Node.js and such.

Seems to be a 5-7 year cycle.

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

#26
post #15

Just remember when you talk about "cool" and popular that, Google+, GMail, LinkedIn, and many parts of Twitter are Java.

For twitter: JVM != Java

Also remember that Google uses C++ as well for their infrastructure

LinkedIn, yep

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

#27
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…

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.

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

#28
We use Java to develop web apps because while we could use anything ( I run a research team) I know that I will face problems downstreaming the work if we do. The application support groups can get a Java developer with a whistle, the same is just not the case for any other language, apart from possibly PHP.

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

#29
post #17

No it is not the coolness factor, it is the paradigm. Java forces you to use OOP and OOP is not very fit for web development: you want to answer fast to a stateless request by checking some data trough different filters (eg a template), you don't want to recreate a full world of objects and pass along some messages.

Hmm, last time I checked all the "new" frameworks were OOP too. Be it rails or django - they all have some kind of OO paradigm they adhere to.

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

#30
Disclaimer: This is cribbed from my upcoming "The Well-Grounded Java Developer"

---------------------

If you investigate Ola Bini's pyramid where languages fall into static, dynamic and DSL layers you'll see his arguments for what type of programming tasks suite which layers. Java sits firmly in the stable layer, and so do all of its various web frameworks.

As expected for a popular and mature language, Java has a large variety of web frameworks, such as these:

Spring MVC, GWT, Struts 2, Wicket, Tapestry, JSF (and other related “Faces” libraries), Vaadin, Play, Plain old JSP/Servlet

Java has no de facto leader in this space, and this partly stems from Java simply not being an ideal language for rapid web development.

The former leader of the Struts 2 project, a popular Java-based web framework, had this to say on the subject:

"I’ve gone over to the dark side :-) and much prefer to develop in Rails -- for the conciseness mentioned above, but also because I don’t ever have to do a “build” or “deploy” step during my development cycle any more. But you guys and gals need to be reminded that this is the kind of thing you are competing against if you expect to attract Rails developers ... or to avoid even more “previously Java web developer” defectors like me :-). Craig McClanahan, Oct. 23, 2007"(http://markmail.org/thread/qfb5sekad33eobh2)

Java is a compiled language, and as alluded to previously, this means that every time you make a code change to a web application, you have to go through all of these steps:

1. Recompile the Java code. 2. Stop your web server. 3. Redeploy the changes to your web server. 4. Start your web server.

As you can imagine, this wastes an awful lot of time! Especially when you’re making lots of small code changes, such as altering the destinations in a controller or making small changes to the view.

If you’re a seasoned web developer, you’ll know that there are some techniques you can use to try and solve this problem. Most of these approaches rely on some sort of ability to apply code changes without stopping and starting the web server, which is also known as hot deployment. Hot deployment can come in the form of replacing all of the resources (such as an entire WAR file) or just a select few (such as a single JSP page). Unfortunately, hot deployment has never been 100 percent reliable, and the web server often still has to perform expensive recompilation of code.

If you must use a Java-based web framework, I highly recommend products called JRebel and LiveRebel (http://www.zeroturnaround.com/jrebel/). JRebel sits in between your IDE and your web server, and when you make source code changes locally, they’re automatically applied to your running web server through some genuinely impressive JVM trickery (LiveRebel is used for production deploys). It’s basically hot deployment done right, and these tools are seen as industry standards for solving the hot deployment problem.

Generally speaking, Java-based web frameworks don’t reliably allow you to have a fast turnaround time for your changes. But that isn’t the only concern with Java-based web frameworks. Another factor that slows down rapid web development is the flexibility of the language, and this is where static typing can be a drawback.

In the early stages of developing a new product or feature, it’s often wise to keep an open-ended design (with regards to typing) of the user presentation layer. It’s all too easy for a user to demand that a numeric value have decimal precision, or for a list of books to become a list of books and toys instead. Having a statically typed language can be a great hindrance here. If you have to change a list of Book objects into a list of BookOrToy objects, you’d have to change your static types throughout your codebase. Although it’s true that you can always use the base type as the type of objects in container classes (for example, Java’s Object class), this is certainly not seen as a best practice—this is effectively reverting to pregenerics Java. As a result, choosing a web framework that’s based on a language in the dynamic layer is certainly a valid option to investigate.

Post reply on HN