Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the relationship between Node.js and V8?

Tags:

node.js

v8

I've been thinking about this question for a while and can't seem to find the answer. What is the relationship between Node.js and V8? and Can Node.js work without V8?

like image 627
Chanlito Avatar asked Mar 06 '17 01:03

Chanlito


People also ask

Is Nodejs based on V8?

V8 is a browser engine whereas nodejs is built on top of V8 which is a runtime environment that gives javascript the power to run at the server-side.

Why does node js use V8?

V8 is required for the current Node. js engine to function. In the absence of V8, it wouldn't have a JavaScript engine, and thus wouldn't be able to run JavaScript code. The V8 interface between C++ and JavaScript is used by the native code bindings that come with Node.

Can Nodejs work without V8?

The current Node. js engine cannot work without V8. It would have no JavaScript engine and hence no ability to run any JavaScript code. The fact is that the native code bindings, which come with Node.

Which engine does Nodejs use?

Node. js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.


2 Answers

What is the relationship between Node.js and V8?

V8 is the Javascript engine inside of node.js that parses and runs your Javascript. The same V8 engine is used inside of Chrome to run javascript in the Chrome browser. Google open-sourced the V8 engine and the builders of node.js used it to run Javascript in node.js.

Can Node.js work without V8?

No. The current node.js binary cannot work without V8. It would have no Javascript engine and thus no ability to run code which would obviously render it non-functional. Node.js was not designed to run with any other Javascript engine and, in fact, all the native code bindings that come with node.js (such as the fs module or the net module) all rely on the specific V8 interface between C++ and Javascript.

There is an effort by Microsoft to allow the Chakra Javascript engine (that's the engine in Edge) to be used with node.js. They build a V8 shim on top of Chakra so that the node.js binary code that expects to be talking to V8 can continue to do what it was doing, but actually end up talking to the Chakra engine underneath. From what I've read this is particularly targeted at Microsoft platforms that already have the Chakra engine and do not have the V8 engine running on them, though presumably you could use it on Windows too.

like image 188
jfriend00 Avatar answered Sep 21 '22 14:09

jfriend00


Node.js can actually function to some extent without V8, through use of the node-chakracore project. There is ongoing work to reduce the tight coupling between V8 and Node, so that different JavaScript engines can be used in-place.

like image 34
Superfly Avatar answered Sep 18 '22 14:09

Superfly