Slashdot Mirror


Java Vs. Node.js: Epic Battle For Dev Mindshare

snydeq writes While it may have been unthinkable 20 years ago, Java and JavaScript are now locked in a battle of sorts for control of the programming world. InfoWorld's Peter Wayner examines where the old-school compiler-driven world of Java hold its ground and where the speed and flexibility of Node.js gives JavaScript on the server the nod. "In the history of computing, 1995 was a crazy time. First Java appeared, then close on its heels came JavaScript. The names made them seem like conjoined twins newly detached, but they couldn't be more different. One of them compiled and statically typed; the other interpreted and dynamically typed. That's only the beginning of the technical differences between these two wildly distinct languages that have since shifted onto a collision course of sorts, thanks to Node.js."

12 of 319 comments (clear)

  1. Ummmm.... by Anonymous Coward · · Score: 1, Insightful

    Java = back end

    JavaScript = front end

    Need both to do useful things, no?

    1. Re:Ummmm.... by NotInHere · · Score: 3, Insightful

      Modern web sites shouldn't rely on Java plugins. There is only one native scripting language for the web, and that's js.

    2. Re:Ummmm.... by robi5 · · Score: 4, Insightful

      The summary is not about node.js vs. the browser, but Java vs. Javascript.

      The main problem with Java (other than the other major problems others listed) is that it's not Javascript:

      1. you cannot realistically avoid Javascript on the client side
      2. the client side is only getting richer in functionality (look up something like dc.js, crossfilter.js, d3.js, Google apps, mapping, all web apps...)
      3. there is benefit to using one language instead of two, if the feature set is comparable: no context switch for programmers...
      4. ... and you can use common data validation (on the client: reject/highlight bad user input without a server trip; on the server: 'never trust the client' principle, infosec)
      5. ... and common aggregation analytics (allow your user to sort, filter, aggregate data, product descriptions, events whatever) between client and server
      6. ... common domain-specific logic, common utilities libraries, DRY principle, no duplicated testing of logic, common development toolchain, we could go on

      So the 'they both have their place' isn't quite true for a very large fraction of deployments which currently use Java on the server (and naturally, JS on the client).

      Javascript is not 'only so performant', and, as someone else below assumed, JS isn't fast 'because of concurrency'. Most JS is run on V8 or similarly advanced engine, and in my experience the resulting code is about as fast (or slow) as Java execution (single threaded) even if we ignore the most often cited benefit of node.js, which is non-blocking IO. As JS itself is evolving, with typed arrays and the possibility of programming it without generating garbage, WebGL, Web workers, and low level numeric and bit logic functions coming up in about a year, so it'll only get faster. It's unlikely Java will ever have a performance lead on JS ever again.

      Using the same language end-to-end is a more powerful argument than 'the right tool for the job' argument, especially if Java's current lead in some specific server side areas (e.g. finance/reliability/type safety aspects, or machine learning) aren't inherently a consequence of the language, just a consequence of a head start in those areas.

      So in my opinion there is a strengthening incentive for using one language end to end at the expense of Java.

    3. Re:Ummmm.... by Dutch+Gun · · Score: 3, Insightful

      I have nothing against Java either, but I think making it web-facing has been something of a disaster from a security standpoint. And let's face it, security isn't a high-priority feature up until you're breached, and then it becomes a critical feature. If you disable the Java web plugin on the client, the language itself really has a lot going for it. If it didn't, so many programmers wouldn't still be using it today - according to some rankings, it's the most popular language right after C, and just before PHP and Javascript.

      Fortunately, given the fact that we have dozens of reasonably popular languages to choose from, and even more obscure ones, we don't have to pick one language to do everything. In fact, it's downright silly to think that one language ever could do it all. The reason we have so many languages to begin with is because there are so many diverse programming challenges and environments in the modern world, and every language has specific strengths and weaknesses.

      --
      Irony: Agile development has too much intertia to be abandoned now.
    4. Re:Ummmm.... by Eponymous+Coward · · Score: 4, Insightful

      I think you would have to be nuts to build something on a Google technology. I thought about it because GWT is very cool, but with my luck I would roll out version 1.0 and Google would cancel that project and donate the code to the Apache orphanage.

  2. Battle for mindshare, or for page hits? by QuietLagoon · · Score: 5, Insightful
    Is there a real battle going on? Or is the battle in the head of some writers who are creating an ersatz battle in order boost their page hit count?

    .
    Computer media are usually pretty dull, so there's nothing like a supposed battle to up the interest.

  3. Some misconceptions by Just+Some+Guy · · Score: 4, Insightful

    1) Languages aren't compiled or interpreted: implementations are. Java has had a decent optimizing compiler for a long time, but JVM 1.0 wasn't exactly a speed daemon. JavaScript was a dog for a long time, but modern engines like V8 compile it to native machine code.

    2) Node.js isn't fast. It's concurrent. You can handle many thousands of simultaneous requests, as long as none of them are working particularly hard.

    3) Exactly what collision course are we talking about? I can't imagine many situations I'd consider Node.js for that I ever would have though about Java for in the first place. If anything, I see Node.js as more of a competitor to Python for building scalable backend services.

    --
    Dewey, what part of this looks like authorities should be involved?
  4. Executive Summary by netsavior · · Score: 4, Insightful

    Node.js - I don't want to pay my programmers
    Java - I don't want to pay microsoft

  5. Re:node is going away. by new_01 · · Score: 4, Insightful

    God I swear the Java world is overrun with this kind of stuff. It requires you to fully jump into their world instead of just using a piece of it happily and moving on with your day. You have to go install the kitchen sink IDE, server, and whatever else. It's a career path just learning all of the lingo.

  6. Massive over generalization much? by JustNiz · · Score: 4, Insightful

    >> Java and JavaScript are now locked in a battle of sorts for control of the programming world.

    Whatever. Wake me up when you can write a (good) device driver in either then I'll take your claim a little more seriously.

    I realise that the internet is a massive source of employment, but believe it or not, its not the only thing out there. There are acutally a few of us software developers left that do not do web stuff (and actually like it that way).

  7. This is not a mindshare battle...at all by MillerHighLife21 · · Score: 5, Insightful

    Javascript, despite it's popularity, is a terrible language. It's popularity is due to one thing, it is embedded in the browser. If you could just pick your own language to embed in the browser, you'd never hear of it. The entire level of popularity from Node.js has come from 3 things:

    1. Frontend (read, client side, not "PHP") developers who get the idea in their head that they already know javascript so wouldn't it be great to use it on the server too so they don't have to learn another language
    2. Non-blocking I/O, which is admittedly very worthwhile on the server side...however, Java still blows it out of the water for concurrency and Go is currently doing everything that Node does here, but better.
    3. AJAX development, making JSON popular, leading to JSON based NoSQL databases like Mongo (which is great at what it does) and then uses Javascript for processing in the database too because of JSON

    There's a 4th reason that gets tossed around that I've never seen actually validated with the idea of "reusing code on the backend and the front-end" but I've never seen a case where that was actually a good idea since it involves exposing so much logic.

    On the frontend, yes, Javascript everything...because you have no other option. That's like saying black was beating green for mind share with the Model T Ford.

    On the backend, you have Java, Go, .NET, Ruby, Python, PHP, Clojure, Groovy, Erlang, Perl, Scala...all of these languages exist with different benefits and different trade offs.

    If anything, a huge piece of Go's skyrocketing popularity is people wanting the non-blocking I/O perk of Node for certain use cases without all of the pain that comes from dealing with Javascript.

    --
    "Don't teach a man to fish, feed yourself. He's a grown man. Fishing's not that hard." - Ron Swanson
  8. Re:node.js (eye rolling) by Shados · · Score: 3, Insightful

    Now that pre-compilation is pretty much pervasive in any advanced browser development, you DO have "real alternatives" to ES5 (probably what you're referring to if you're mentioning being stuck with it).

    CoffeeScript, TypeScript, ES6, Clojure, hell, Scala is available, and you can use Java with stuff like GWT (imo sucks, but Amazon thought it was great for a while).

    People keep going back to JavaScript because, aside for a couple of stupid things (a lot of which are fixed with strict mode and ES6 constructs), its actually pretty damn good, and some things that used to be considered hacks or half baked, like prototypical inheritance, are starting to be viewed as superior to the alternative, with good reasons.

    But even without that, the reason people will use node on the server, when its not for isomorphic app (which btw, is a REALLY good way to build your app, if you can afford the development overhead and care about your customers), is because the threading model of Node/V8 has very interesting performance and scaling characteristics for I/O heavy applications. It can scale like fucking crazy. http://blog.caustik.com/2012/04/10/node-js-w250k-concurrent-connections