where does node.js fit within the web development context?

前端 未结 3 1535
逝去的感伤
逝去的感伤 2021-02-09 06:39

I know that node.js is said to be \"event-driven I/O\" server-side javascript hosted on V8 Javascript engine. I visited the node.js website, and then read the

3条回答
  •  借酒劲吻你
    2021-02-09 06:55

    The node.js server is, in simple terms, a replacement for something like the Apache web server - but it is largely written in JavaScript which runs on the server (executed by the V8 engine) rather than on the client side. It can be extended with 'native code' modules (written in e.g. C++) wrapped in a JavaScript interface to add functionality, but AFAIK most node.js modules are pure JavaScript.

    "Event driven I/O" is just a term that describes the normal asynchronous callback mechanisms you're used to in JavaScript. In node.js you supply callbacks for all sorts of things, and your function is called when the relevant event occurs.

    Depending on how many modules you add, a node.js server is relatively lightweight compared to something like Apache, and in some ways a lot simpler.

    The two main advantages to node.js I see are:

    1. It allows you to write both the server-side and client-side parts of a web application in the same language. In some cases you can use the same code on both sides.
    2. It makes server-side coding accessible to all those web developers out there that know JavaScript without having to learn a more common server-side language like PHP or Java.

    Here's an article I just came across that might also shed some light: What is Node.js?

提交回复
热议问题