Node.js 与 Tomcat 的不同之处 [英] How Node.js is different from Tomcat

查看:34
本文介绍了Node.js 与 Tomcat 的不同之处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Node 的新手并且仍在经历它.我有一些疑问:

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

  1. 作为服务器端框架,它与 Tomcat 有何不同?
  2. 如果我正在生成一些 REST API,我可以将它们托管在 Node 服务器上还是需要另一台服务器?

推荐答案

回答你的第一个问题,Tomcat 和 Node 完全 是不同的野兽,尽管你可以让 Node 与 Tomcat 服务于相同的目的如果您不知道要使用的编程语言,并且在其上添加了正确的内容.

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 是一个 Web 服务器,用于 Web 应用程序java.
  • Node 是应用程序运行时环境javascript.
  • Tomcat is a web server for web applications written in java.
  • Node is a runtime environment for applications in javascript.

因此,除了编程语言的差异之外,您所做的比较并不是真正均匀的.你看,Node(加上底层的 V8 引擎)更像是 JVM(Java 虚拟机)而不是 Tomcat.

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.

您可以在 Node.js 上开发任何类型的应用程序.其中一个子集是服务器应用程序,然后是 Web 服务器应用程序的一个子集.

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.

现在,Node 上最常用的 Web 服务器可能是 Express.老实说,我不知道另一个.我找到了 Express,但从未寻找过其他任何东西.

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

至于您的第二个问题,是的,您可以在 Node 上构建 REST API,前提是您在其上添加 Express.好消息是它非常简单.看看这个:http://expressjs.com/en/guide/routing.html

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: http://expressjs.com/en/guide/routing.html

祝你好运,学习 Node.js 玩得开心.我有吨.离开 Java 并从不回头;)

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

这篇关于Node.js 与 Tomcat 的不同之处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆