Live data from Hacker News

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

programmers.stackexchange.com

71–80 of 188 posts

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

#71
post #66

Earlier quoted context omitted.

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

> At the cost of throwing internationalisation out of the window. At least the example you led with is more conducive to localisation. Right. i18n is the reason you have to import two taglibs and the template doesn't support basic conditionals. /s JSP is horrendous. There is not a single reason for its existence, and it should be quarantined. As far as i18n/l10n goes, the example I quoted was from play framework. Thi…

The JSP one looks cleaner, and more readable, even though both code-blocks now smell of taglib.

> I tried really hard, but I failed to think of a single templating engine that's worse than JSP.

XSLT

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

#72

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 la…

"1. Recompile the Java code. 2. Stop your web server. 3. Redeploy the changes to your web server. 4. Start your web server. ... Unfortunately, hot deployment has never been 100 percent reliable, and the web server often still has to perform expensive recompilation of code." - Last I checked i) the hot deployment in Tomcat/Jetty/SBT/etc is pretty solid, especially if we are talking development. ii) Java supports incre…

Not only does hot deployment work almost always, so does in-place compilation of modified code within deployed modules while connected to a remote application server in debug mode.

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

#73
post #66

Earlier quoted context omitted.

> At the cost of throwing internationalisation out of the window. At least the example you led with is more conducive to localisation. Right. i18n is the reason you have to import two taglibs and the template doesn't support basic conditionals. /s JSP is horrendous. There is not a single reason for its existence, and it should be quarantined. As far as i18n/l10n goes, the example I quoted was from play framework. Thi…

The JSP one looks cleaner, and more readable, even though both code-blocks now smell of taglib. > I tried really hard, but I failed to think of a single templating engine that's worse than JSP. XSLT

> The JSP one looks cleaner, and more readable,

There is no accounting for taste. Importing taglibs for when and size, this monstrosity which is apparently an if condition(who would have known):

        
            You have ${fn:size(emails.unread)} unread email(s)!
        
and it's not i18n'd yet. If it somehow looks cleaner to you, well, keep using it.

> even though both code-blocks now smell of taglib.

Groovy template has if tag built in. How does a simple if-else condition smell of taglib?

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

#74
post #59
post #29

Earlier quoted context omitted.

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.

Yes, and there is this ORM impedance mismatch thing. I stopped writing classes for all tables and it removed many useless code and many issues related to stateful methods. Just one example: if you delete a book with book.delete() then how come you can two or many lines later change its title with book.title = Foo?

You can't. The JVM will tell you that the book object you are referring to no longer exists. I'm assuming your delete() method did actually remove the object.

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

#75
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. Also very very much fashion lead by hipsters who must be using the newest coolest untested thing on the planet.

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

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

#76
I've worked with PHP for 16 years, and with Grails for almost 5. There are some aspects of Grails and Groovy that make me more productive than developing in PHP. GORM simplicity and expressiveness, and CriteriaBuilder stuff, combined make using direct SQL very rare (required in a few cases, but rare).

However, there are aspects of PHP that make things more simple, and this gets down to somewhat of a cultural thing. Of the PHP people I know, many (most?) of them have done some server setup and understand the entire request stack. I know a lot of PHP people don't grok all that as well, but of the people I know personally, many do. That number is far higher than the number of Java folks I know who really grok the full web stack. I'm not saying none do, but... many don't have to as much as PHP folks.

A friend of mine who's done Java for a decade (and Groovy some too) was confused by a complaint I was having about Java web stuff. Specifically, I was (am?) having some trouble getting session replication stuff working. We need to load balance web servers, and I really want to avoid server affinity on a load balancer. In PHP, sessions are serialized to disk, but serializing to memcache or some other database is pretty simple. Java... not so much.

My friend's confusion was "why are you doing that? just tell the ops guys to set it up". Well... I am the ops guy. Which gets to the culture of dev stacks. Historically, the Java shops I've seen inside are larger, and there's a bigger separation of concerns - the server/ops person often isn't even much of a developer, they just drop in a war file and keep websphere running, etc. Again - YMMV, but that's been mostly what I've seen.

The 'separation of concerns' here is the heart of the issue. In PHP, all session stuff is handled in code. In Java... well, your app server takes care of that for you - 'out of the box' you don't have any real direct control over how they're handled, and configuration of such is never done in code, but at the server level.

I'm reminded of PHP in 96/97. If you were doing PHP back then, it's because you really loved it, not because it was your job, and you really needed to grok everything about everything to get it set up and working (locally, anyway). If you're really set on using alt.java tech, you likely have a greater commitment to getting your hands dirty in multiple levels.

disclosure - i run groovymag.com and have a bias towards all things grails and groovy :)

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

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

...and that is why the latest generation of JVM languages such as Scala, Clojure and Groovy are so popular. Java the platform is extremely stable, highly optimized and heavily instrumented. Java is much less verbose than C++ (the main alternative when it was released), but the times have moved on.

With Scala statically typed and verbose are not synonymous. Statically typed = high performance. Type inference and compact syntax = expressive. Best of both worlds. Languages like Ruby bring expressive syntax, but performance suffers. Performance is becoming increasingly important with mobile applications, one of many reasons Ruby adoption has stagnated since the end of 2010 (see open source contribution and indeed.com charts).

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

#78
post #72

Earlier quoted context omitted.

"1. Recompile the Java code. 2. Stop your web server. 3. Redeploy the changes to your web server. 4. Start your web server. ... Unfortunately, hot deployment has never been 100 percent reliable, and the web server often still has to perform expensive recompilation of code." - Last I checked i) the hot deployment in Tomcat/Jetty/SBT/etc is pretty solid, especially if we are talking development. ii) Java supports incre…

Not only does hot deployment work almost always, so does in-place compilation of modified code within deployed modules while connected to a remote application server in debug mode.

To both of these points, you still have classloader issues which cannot be resolved (App/Web server vs application classloading). This is one of the reasons that Java 8 is going down the modular Jigsaw route (taking ideas from OSGi along the way). Some web/app servers have put together clever tricks over the years and JRebel also helps, but it's certainly not foolproof.

I'll concede that the static vs dynamic language gap is narrowing in terms of flexibility (and yes BookAndToy is a _very_ contrived example), but dynamic language fans love the fact that you don't have to refactor at all.

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

#79
post #66

Earlier quoted context omitted.

> At the cost of throwing internationalisation out of the window. At least the example you led with is more conducive to localisation. Right. i18n is the reason you have to import two taglibs and the template doesn't support basic conditionals. /s JSP is horrendous. There is not a single reason for its existence, and it should be quarantined. As far as i18n/l10n goes, the example I quoted was from play framework. Thi…

I like JSPX. Designers and HTML front-end engineers intuitively understand custom tags, and any imperative non-declarative logic should ideally be pushed back into Java or a custom JSP tag, such that you rarely see it.

> Designers and HTML front-end engineers intuitively understand custom tags, and any imperative non-declarative logic should ideally be pushed back into Java or a custom JSP tag, such that you rarely see it.

Have you used other templates say Jinja2 or Django templates? The traits you listed aren't unique to JSPX. Jinja2 is designer friendly, doesn't have non-declarative logic, and is pleasant and concise to use.

ERB(or slim or haml) allows embedding code in templates, but that doesn't mean you are mandated to do it. Java will allow you to put n non-public classes in one file - that doesn't mean you code your whole app in a single .java file. Just because it's possible is hardly an excuse for it being bad.

There are use-cases where code in templates are useful. I would rather not jump through the hoops of defining a custom tag for an one-off use-case.

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

#80

I've worked with PHP for 16 years, and with Grails for almost 5. There are some aspects of Grails and Groovy that make me more productive than developing in PHP. GORM simplicity and expressiveness, and CriteriaBuilder stuff, combined make using direct SQL very rare (required in a few cases, but rare). However, there are aspects of PHP that make things more simple, and this gets down to somewhat of a cultural thing. O…

Groovy, Scala + Clojure = next generation of languages being adopted by Java devs. All the things we love about Java combined with a more modern syntax.
Post reply on HN