Chandan Gupta Chandan Gupta - 28 days ago 7
Node.js Question

How Node.js is different than tomcat

I am new to Node and still going through it. I have some doubts:

  1. Being a server-side framework, how is it different than Tomcat?

  2. If I am producing some REST APIs, can I host them on a Node server or do I need another server?

Answer Source

To answer your first question, Tomcat and Node are completely different beasts, although you can get Node to serve the same purpose as Tomcat if you're agnostic to the programming language you're going to use and you add the right stuff on top of it.

  • Tomcat is a web server for web applications written in java.
  • Node is a runtime environment for applications in javascript.

So apart from the difference in the programming language, the comparison you're making is not really even. You see, Node (plus the underlying V8 engine) is more of the equivalent of the JVM (Java Virtual Machine) than Tomcat.

You can develop any type of application on Node. A subset of those will be server applications, and then a subset of that will be web server applications.

Now, perhaps the most commonly used web server on Node is Express. I honestly don't know of another. I found Express and never looked for anything else.

So, for the purpose of comparison, think of it like this:

JVM vs. V8+Node
Java vs. Javascript
Tomcat vs. Express

As for your second question, yes you can build REST API's on Node, provided you add Express on top of it. And the good news is that it is extremely simple. Have a look at this:

Good luck and have fun learning Node. I had tons. Left Java and never looked back ;)