Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Microsoft's ChakraCore provide any performance benefit over Google's V8 when used as JS Engine for Node.js [closed]

Tags:

[I have Edited my question to narrow down the scenario to only Node.js. Please Re-Open it. It is a helpful question and Proper answers might come in future and not sooner as ChakraCore is still at very young age. But this question is Valid and Should be here]

We all have known / read / heard about the glory of Google's V8 Engine and how it has made node.js the beauty it is, for years.

But now that we have an option to choose between Microsoft's ChakraCore and Google's V8 as our preferred JavaScript Engine, I am wondering if someone has any evidence, or test cases where they have found one to be more efficient than another for nodejs.

Please back your answer with some facts and results, because someone should not be using/choosing Chakra only because he/she loves Microsoft or and same applies for V8 and Google.

Thanks.

like image 509
Suman Barick Avatar asked May 24 '16 07:05

Suman Barick


People also ask

Why does Google use the V8 engine for Node JS?

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.

What is the difference between node JS and V8?

Node. js is just a runtime environment that supports the execution of a program. V8 is at the core of Node.

What is V8 JavaScript engine used for?

Chrome V8 is a JavaScript engine, which means that it executes JavaScript code. Originally, JavaScript was written to be executed by web browsers. Chrome V8, or just V8, can execute JavaScript code either within or outside of a browser, which makes server-side scripting possible.

Is V8 better than SpiderMonkey?

V8 is the fastest, because it compiles all JS to machine code. SpiderMonkey (what FF uses) is fast too, but compiles to an intermediate byte-code, not machine code.


2 Answers

How they are different?

Whereas most modern JavaScript engines translate all JavaScript code into efficient machine code (source), Chakra has an intelligent and high-performance interpreter. This interpreter has intelligent heuristics that can determine whether to compile your code into machine code or interpret it. An interpreter is usually faster to start and requires less memory to run, which makes Chakra very attractive for resource-constrained environments (such as a Raspberry Pi).

In 2015 Microsoft introduced support for Node.js with Chakra to allow developers to target the Windows IoT Core platform. The recent open-sourcing of ChakraCore has allowed Microsoft to develop in the open and align better with Node.js release schedules.

In a recent JavaScript Air episode, Steve Lucco mentioned that the Chakra team are planning to "really take the community seriously and take their input seriously in terms of the direction that the engine will go [and] give the community a lot more input than, for example, they have had in the direction of V8".

In striving to build a memory efficient JavaScript engine, Microsoft have actually built a competitively fast one. At the time this article was written, Chakra outperformed V8 in some cases:


(source: msecnd.net)

Benchmarks aren't necessarily indicative of real-world performance but this competition in VM performance will eventually lead to a faster Node.js runtime for users of all VMs.

It's also worth mentioning that having their own JavaScript engine will allow Microsoft to freely innovate. One early innovation is time-travel debugging.

like image 102
Alex Booker Avatar answered Nov 23 '22 22:11

Alex Booker


How they are different?

Well the question is bit too broad to answer currently in the format but i will try answering it.

Google's V8 engine has all the features which is required to have a blazing fast performance out of it. So, basically this one is the base for the nodejs for quite a while and it will be there for long run.

On the other hand Microsoft's ChakraCore is also been actively developed and it has two layer structure (unable to name it) with Chakra Shim and ChakraCore.
Thing to notice Chakra Shim implements the most essential V8 APIs so that the underlying JavaScript engine change is transparent to Node.js and other native addon modules written for V8.

Source: NodeJs-ChakraCore

For OP: Look for webassembly too.

like image 36
Jai Avatar answered Nov 24 '22 00:11

Jai