Live data from Hacker News

Why is a Java guy so excited about Node.js and JavaScript?

blog.sourcerer.io

81–90 of 117 posts

Re: Why is a Java guy so excited about Node.js and JavaScript?

#82

I develop a very complex, 500K+ LoC Java application. It implements a natural language sentence parser that is integrated with a specialized lossless data compressor. I use: - No IDE, just a simple text editor - No ORM, hand-written SQL code - My build tool is a Python script that marshals a javac call - I have just a few JAR file dependencies, which are checked into the repo - My own simple unit test and integration…

What made you create your own build tool rather than use Maven or Gradle? Ditto for the unit tests; why does JUnit not fit you?

Re: Why is a Java guy so excited about Node.js and JavaScript?

#83
The author compares Spring and Java EE vs. Node.js. But these three things can do very different things. It would be better to compare Node.js with something like Reactor or RxJava and a reactive Web framework like WebFlux.

> Dahl’s experience was that using threads made for a heavyweight complex system. He sought something different, and spent a couple years honing and refining a set of core ideals arriving at Node.js. The result was a light-weight system, a single execution thread, an ingenious use of JavaScript anonymous functions for asynchronous callbacks, and a runtime library that ingeniously implemented asynchronicity.

He cured the symptom with an oversimplified solution. Having only one thread per process is a severe limitation. It would have been better, to create good APIs (like Reactor or Kotlin coroutines) or language-level solutions (like Rust) to handle multi-threading.

> In Java. Listeners require creating a concrete instance of an abstract interface class.

That is no longer true, since event handlers can be defined as anonymous functions since Java 8 (from 2014).

> Another learning: Most programming languages obscure the programmers intent, making it harder to understand the code.

The author mixes Java the language, Java the platform and libraries/frameworks, so it is worth pointing out, that the Java ecosystem is not limited to the Java language. Using Kotlin or Scala would remove his reasons to complain.

> JavaScript, by contrast, has loosey-goosey typing. The theory is obvious: The programmer has no certainty what kind of object they’ve received, so how can the programmer know what to do?

You have to make certain assumptions to handle incoming data, but it would be good for robustness and security to make these assumptions explicit. And, really, converting a Json string into a Java object is a single line calling Jackson and maybe a few annotations.

The section about modules could be applied to Java 9+ as well.

Re: Why is a Java guy so excited about Node.js and JavaScript?

#84
> Both Java and Node.js offer excellent performance, running counter to the myth that JavaScript is slow and therefore Node.js performance must be bad

> Node.js performance is riding the coattails of Google investment in V8 to speed up the Chrome browser

> The intense competition between browsers is making JavaScript more and more powerful every year, benefitting Node.js

Sounds ammmmazing! So JS is really damn fast and on a par with Java, right? But wait, are there any numbers?

https://www.techempower.com/benchmarks/#section=data-r16&hw=...

Ouch.

Re: Why is a Java guy so excited about Node.js and JavaScript?

#85
post #9

This person definitely needs to try out some JVM languages like Scala, Kotlin or Groovy. They solve nearly everything he talks about while keeping the good parts of the JVM ecosystem and avoiding a lot of the bad parts of NodeJS.

No love for Clojure? I know many people that swear by it.

I'm not saying that clojure is bad, but if you look at any language popularity index it is very rarely used in general.

Re: Why is a Java guy so excited about Node.js and JavaScript?

#86
post #26

I expected (2012) after the article's title. This type of hype about Node and JS is long gone I'm afraid.

I’m not so sure about that. I see node getting more and more traction these days. In 2012 it was a hipster tech, in 2018 it’s actually starting to see its way into production. At least around here, my own place included. We’re a .net shop, like half the country I live in, but I could’ve written a somewhat similar story as the author. Not exactly similar, I don’t think NPM is really better than maven or nuget and comi…

Have you ever had to survive a oenetration test on the node app? A lot of cases I see. The JS side is much lower friction because a lot of the security stuff is omitted.

Re: Why is a Java guy so excited about Node.js and JavaScript?

#87

Obviously Java's type-checking compiler is a benefit for large projects. How could JavaScript ever address its lack of that? Well JavaScript is a dynamic language, it can check types at runtime. Combined with unit-testing that can go a long way without requiring that "everything must always be type-checked". For instance it makes sense to declare the types of public interfaces of a class, maybe not so much every vari…

Your point doesn't make sense... you talk about the weakness of not being type checked, then say it's ok because that happens at runtime?

Re: Why is a Java guy so excited about Node.js and JavaScript?

#88
post #51

Earlier quoted context omitted.

Pip freeze is dead simple and I upgrade packages as needed. I've rarely manually updated requirements.txt. I literally make a venv, pip install what I need and I am off and running. My editor/ide automatically recognizes the environment. I can't imagine how much simpler it could be. I've been doing it for years without any problems. Dependcies, versioning etc are incredibly simple. A couple commands and I am up and r…

I'm glad that the workflow works so well for you. In my case, it doesn't. I'm maintaining libraries and also applications that use those libraries. For libraries, you need your setup.py to be kept up to date, as requirements.txt doesn't do anything when you pip install a library package. Of course, requirements.txt is necessary when you want to run the libraries's tests, since few things are as frustrating as having…

You seem fixated on setup.py I have literally never cared about that file in 20 years of python development. Keep the work flow simple and problems tend to disappear.

Re: Why is a Java guy so excited about Node.js and JavaScript?

#89
post #9

This person definitely needs to try out some JVM languages like Scala, Kotlin or Groovy. They solve nearly everything he talks about while keeping the good parts of the JVM ecosystem and avoiding a lot of the bad parts of NodeJS.

For a long time I worked with Java and tried to make the move to Groovy since I could appreciate what I read about it, having a background in Smalltalk. But somehow using Java for some large projects just seemed more straightforward and safe, because of type-checking which supports large-scale refactorings. But since I moved to mainly work on Node.js I feel that Node.js is what Groovy should have been. A simple but a…

> Use JavaScript as "glue for Java" like it was originally intended.

Then we would have come full circle. JavaScript was originally intended as glue for Java applets, but applets never became popular. Instead, Java was used for standalone and server-side codebases, and Beanshell came along as glue code for those. Later, James Strachan added closures to Beanshell's basic functionality, and Apache Groovy was born. Afterwards, Scala became popular and showed that a statically-compiled language could be used dynamically as well, and Strachan said if he'd known about Scala at the time, he'd never have created Groovy. Later, Kotlin showed you could even have builders in statically-compiled code. Now Graal is finally enabling Javascript on the JVM, perhaps selling the idea to developers better than Rhino or Nashorn did.

Re: Why is a Java guy so excited about Node.js and JavaScript?

#90
post #26

I expected (2012) after the article's title. This type of hype about Node and JS is long gone I'm afraid.

I’m not so sure about that. I see node getting more and more traction these days. In 2012 it was a hipster tech, in 2018 it’s actually starting to see its way into production. At least around here, my own place included. We’re a .net shop, like half the country I live in, but I could’ve written a somewhat similar story as the author. Not exactly similar, I don’t think NPM is really better than maven or nuget and comi…

.NET Core took a lot of ideas from the node platform. Have you tried this?
Post reply on HN