Can we say node.js is a web server?

后端 未结 9 604
孤街浪徒
孤街浪徒 2020-12-22 15:56

I found that I am confusing between web framework and web server.

Apache is a web server.

Tornado is a web server written in Python.

9条回答
  •  生来不讨喜
    2020-12-22 16:37

    I would say Node.js is a Runtime Environment or a Runtime Engine.

    Probably the best definition I have found so far comes from an article by Rob Gravelle entitled "An Intro to Node.js":

    Node.js is part runtime environment and part library for building network applications using server-side JavaScript. It uses Chrome's JavaScript runtime engine to execute JS code directly without the need for the browser sandbox.

    Also the PCMAG.COM Encyclopedia provides the following definition of "runtime engine":

    Software that certain applications depend on to run in the computer. The runtime engine must be running in the computer in order for the application to execute. It provides common routines and functions that the applications require, and it typically converts the program, which is in an interim, intermediate language, into machine language.

    Also the Wikipedia article entitled "Run-time system" declares:

    A run-time system (also called runtime system, runtime environment, or just runtime) implements the basic behavior of a computer language, whether the language is a compiled language, interpreted language, embedded domain-specific language, or is invoked via an API as is pthreads.

    ... A run-time system may implement behavior of tasks such as drawing text on the screen or making an Internet connection. It also typically acts as an abstraction layer that hides the complexity or variations in the services offered by the operating system.

    Well, are there any runtime environments (or even software platforms) like Node.js out there? I guess JRE is a good example of such an environment. Node.js and JRE - they have many in common. They all have (a kind of) virtual machine, a class library and a framework to implement many types of applications, including CLI ones.

    So, getting back to your question, can we say that Node.js is a web server? Let's change "Node.js" for "JRE" and answer if JRE is a web server. The answer is no.

    All that we can say is that Node.js is a runtime environment which one may use to implement a web server. Well, that's my opinion.

提交回复
热议问题