Live data from Hacker News

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

programmers.stackexchange.com

81–90 of 188 posts

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

#81
post #35

Java is a language that is in a weird space. It doesn't compile to binary like C/C++ and it isn't high-level and interpreted like a Ruby or Python. It's a weird middle-times language. It originally appeared in 1995 and is somewhat pioneering in the web space. But it isn't as clean as C# since C# appeared in 2001 and was able to learn from the mistakes of Java. It's definitely not as clean as Go which appeared in abou…

"Tyranny of choice is a problem with Java frameworks."

Similar to PHP, moreso than (almost?) any other dynamic language.

Greenfield choice for me in Java would be Grails.

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

#82
post #52
post #41

Earlier quoted context omitted.

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

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, # means, what : means, etc etc etc.

Add to that, in your example, if you typo one of those characters, your code may well still run, but will fail. With Java, if you typo a single character, it's more likely the code just won't compile.

We could all code in regular expressions or something akin to that, maybe perl one liners. But "number of characters" isn't a good aim. Readable, maintainable, well written code is.

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

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

> XML has absolutely nothing whatsoever to do with Java the language.

Weren't we talking about what OP said, and how per you, it's being averse to thinking?

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

Now if some framework has achieved this level of retardation, I would rather not think about it. There are better things to think about. I would be absolutely fine being averse to thinking about it.

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

#84

As a young developer (early 20's) I think Java's lack of usage in webdev has to do with several "problems". 1.) Java has the rep of being bloated and slow. (At least when compared to C/C++) 2.) Related to #1, almost all the tools the majority of webdevers use are written in C/C++ and not Java. For instance, Apache, Nginx, Redis, MongoDB, MySQL, SQLite, Webkit, V8 - which gives me the feeling that using/improving C/C+…

You're criticizing Java for being slow, and then presenting Ruby as an alternative. You do realise that Java is up to 100 times faster than Ruby: http://shootout.alioth.debian.org/u32/benchmark.php?test=all.... And on multicore systems Java up to 300x faster than Ruby: http://shootout.alioth.debian.org/u64q/benchmark.php?test=al...

...alternatively combine the performance of Java with a highly expressive language e.g. Scala

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

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

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

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

That's a funny complaint when evaluating 4 lines of code one of which is end.

Java makes the assumption that you need a lot of boilerplate code, so being able to make changes easily seems like a big deal. Other languages avoid that boilerplate and can make the changes just as easily for free.

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

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

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.

Actually, with Java, I type more than I think. A lot more.

Compare this to Haskell, where a single keyword might involve substantial thought, or APL, where one character more or less could represent a pretty fundamental restructuring of part of the program.

That Java makes you repeat yourself is not controversial. That being averse to this means you dislike thought is a somewhat bizarre position to hold.

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

#88
Some syntax issues (no function pointers, no lambda, no rich literals, enforcing everything to reside in an object) endears it to Enterprise OO mindset where you want large teams of programmers working "efficiently" - but ultimately a risk conscious and ego driven manager just wants a large team of developers to further their career - and doesn't care how much boilerplate is present or how few lines of code actually do something productive. These are slowly being addressed with newer versions of Java, but it's a long hard road out of hell... and the mental association of Java as enterprise VB is here to stay.

I'd say it's guilt by association with the early years of a java. It reminds lots of people of the bad old days of programming. Getters and setters instead of pure data. Using java objects to hardcode schemas in the middle tier. Horrendeous death by meaningless patterns (form over function). Gigantic libraries configured by XML (how can you take a modern language seriously that doesn't have rich literals). Build dependencies and process that again can't be efficiently specified in the native literal forms of the language.

Finally Java has no useful pedigree as a client side or UI language. Thus the J2ME fiasco. The AWT fiasco. The android sluggish UI fiasco.

You can write a modern web app in BCPL, or Java. But for many people the other options are simply more appealing.

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

#89

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…

I can't see why you can't serialize session to database or memcache or anything else if you want. The amount of code involved is almost zero... Also I don't see a reason to have a shared storage for session objects in a scalable distributed application you are trying to build.

In Java you could, for example, use ehcache with out-of-box replication - simpler than using external C-based application like memcache.

And in Java world you have to deal with different applications servers (Weblogic/WebSphere/JBoss etc.) where apache http and nginx installation and configuration is very primitive in comparison. Yes, it involves sharp skills when it comes to huge loads and replication, but that's another story.

Your friend is probably a young junior developer, you can't be a serious java developer without a decent server skills - there is no ops team at home to do it for you and you can't really gain a lot of knowledge only doing stuff at work.

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

#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 deficiencies does renaming identifiers make up for?

Other than renaming(which can be done for ruby, though it requires manual effort), there is no refactoring which Java does better than Ruby.

> Actual concurrency!

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.

As far as concurrency at language level goes, very rarely have I needed to spawn a thread(I go for gevent) in the controller. Controller's job is to dispatch ASAP - everything else goes in the queue where you use EventMachine or gevent or whatever if you need concurrent processing.

> Faster server spinup and incremental changes. Rails with 20 gems in development mode is super sluggish.

Rails is more sluggish compared to "stop the world. I am compiling" Eclipse?

> Better library ecosystem! > Better dependency management system (maven > rubygems)

As long as we are just throwing out claims without backing them, ruby library and bundler/gem are 1000x better than mvn.

> Better debuggers > Better profilers

Not everyone is a fan of graphical everything. Going by this line of reasoning, Windows has better support for git because gui?

> Easier deployment and ops environment(java -jar myjar, vs bundle install, ruby/passenger/unicorns)

`java -jar myjar` starts your app server, your web server, minifies your css, js, migrates the db....? You can very well bundle the dependencies along with your app for rails, but I don't see why I would do it for a webapp. Also, your jar works only when you don't have java calling into native code. If you don't have native extensions, ruby is platform independent as well(i.e can be bundled).

> Reasonable in-process metrics

No ideas. What's that?

Post reply on HN