• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Is there any scenario when we should go for NodeJS REST API instead of Java REST API?

 
Ranch Hand
Posts: 1257
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can build REST api using Java and we can build using NodeJS too. Is there any scenario when we should go for NodeJS REST API instead of Java REST API?
Thanks
 
Saloon Keeper
Posts: 5809
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's an implementation decision that is not affected (and does not affect) by the overall design. If you already have Java REST code (and developers familiar with that), it may make sense to keep using that. Similarly with Node.js.
 
Monica Shiralkar
Ranch Hand
Posts: 1257
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. In case, it is not the case of existing REST APIs and the team has equally good skills for both Java and NodeJS then how should it be decided in such a case?
 
Tim Moores
Saloon Keeper
Posts: 5809
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are other factors you might want to consider. For example, node.js is its own separate server, whereas JAX-RS runs inside a servlet container. If you already have servlet containers running anyway, you may be able to use those to host the REST services as well. Or at the least you can leverage your knowledge of hosting servlet containers, if it has been decided that the REST services need their own server.
 
Monica Shiralkar
Ranch Hand
Posts: 1257
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It will be like diverting from the question but does creating Node.js REST API come under serverless programming?
 
Tim Moores
Saloon Keeper
Posts: 5809
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Node.js is very much a server, just like any servlet container.
 
Monica Shiralkar
Ranch Hand
Posts: 1257
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You
 
Saloon Keeper
Posts: 2722
354
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Monica Shiralkar wrote:... does creating Node.js REST API come under serverless programming?


Do you mean serverless computing - where the application is executed in a (third-party) cloud environment?
 
Monica Shiralkar
Ranch Hand
Posts: 1257
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I meant serverless computing. I have seen that in cloud. But node.js definitely has server.
 
Ron McLeod
Saloon Keeper
Posts: 2722
354
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that context, the server refers to the computing platform, not the role in a client-server architecture.
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Node JS is offering javascript coding, so it's quit faster than Java while execution. Node js is better in performance while it comes to handle rest apis comaprig with Java.

But there are some limitations with Node JS as well as it is built for small and less complex applications only. But Java built for large scale and highly complex applications too.

So now is up to you that how Is your application made for and used for. Hope it will be useful to you.
 
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

SunilK Chauhan wrote:Node JS is offering javascript coding, so it's quit faster than Java while execution. Node js is better in performance while it comes to handle rest apis comaprig with Java.


Please cite your sources for this claim.

But there are some limitations with Node JS as well as it is built for small and less complex applications only.


Similar, please.
 
SunilK Chauhan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check website : https://www.educba.com/java-vs-node-js/

And checkout Key difference section for more info.
 
Tim Moores
Saloon Keeper
Posts: 5809
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A web site with banners advertising training for technology X is hardly an unbiased source of information about X.

I, too, would question claims that Node.js is generally faster than Java, although it may well be in specific circumstances.
 
SunilK Chauhan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart form the given points, Node js is also quit better in memory efficiency. Package size of Node js also smaller than Java.
 
Saloon Keeper
Posts: 21133
134
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

SunilK Chauhan wrote:Apart form the given points, Node js is also quit better in memory efficiency. Package size of Node js also smaller than Java.



I am skeptical about that, having seen the horrific package load that a simple Node Express app demands. Java isn't exactly modest, but I think it can still do better than that.

Doesn't matter, memory's practically free these days.

I use NodeJS when I need a quick-and-dirty app where performance under load and security are not issues. For industrial apps, I use Java. Both have their places.
 
Marshal
Posts: 7181
492
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:I use NodeJS when I need a quick-and-dirty app where performance under load and security are not issues. For industrial apps, I use Java. Both have their places.


That quick and dirty may imply some background, that systems built with Node.js indeed are that. I recently started my MSc course, and having a module called Component Based Software Development, basically we use Node.js mainly there, and I didn't get an impression that we go dirty route, altough I see an ability to go down that way what you are saying.

So perhaps would be more correct to say, that quite a few misuse this technology?

Note: worth noting, that my knowledge of Node.js is fairly limited as of now.
 
Tim Holloway
Saloon Keeper
Posts: 21133
134
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me, quick-and-dirty is a bit redundant, since computers pretty much conspire to ensure that anything that can be done in a hurry is littered with caltrops. But I still prefer the phrase, since it contains an explicit reminder that everything has its price.

Again, speaking for myself, "quick-and-dirty" implies that minimizing the time-to-delivery is the priority, not robustness or security. Any loosely-typed language (such as javascript) gets automatic dirty-points because they've forced the choice between careful vetting of data usage onto the developer, who is then free not to do so, especially when the boss is breathing down "Git 'er Dun!" Java, being strongly-typed, does that checking automatically. At the cost, of course, of having to code more carefully and think further ahead.

One of the most commonly-used micro-services on my own LAN is a NodeJS program. I have a neat little device I built hanging on my kitchen wall near the door. It has an e-ink display and builtin WiFi node. Once a minute, it sends out a ReST request to an in-house server to get the time of day in minutes (e-ink is best when the display doesn't change too often). That server also runs a cron task at 4am each morning to the local National Weather Service node. Well, actually, it's national, but for my own locality. That task reads weather predictions and squashes them down to a 1-word verdict for the workday, which is then saved and repeated as needed. Also, the same micro-server contacts my home automation server to get the current outside temperature and the message-of-the-day.

All of this is a fairly small NodeJS aggregator. It doesn't need speed, it's not accessible outside the LAN - and doesn't contain anything critical anyway. And it wasn't worth spending several days making a Java webapp out of it. I can live with the relative fragility of a JavaScript app here since even when it does occasionally go pong, nothing worrisome happens.
IMAG0336.jpg
[Thumbnail for IMAG0336.jpg]
Off to work we go!
 
It means our mission is in jeapordy! Quick, read this tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!