Voice of a Developer: ChakraCore JavaScript Engine By Microsoft - Part 30

JavaScript is a language of Web. This series of articles will talk about my observations learned during my decade of software development experience with JavaScript.

Before moving further let us look at the previous articles of the series:

In this article, I am going to explore new JavaScript Engine Chakra by Microsoft.

Introduction

ChakraCore is a new JavaScript engine developed by Microsoft. It doesn’t support IE9. The cool thing about ChakraCore is that it is OSS (Open Source Software). ChakraCore is the core part of the Chakra JavaScript engine and source code is available at GitHub.

It is part of Microsoft Edge browser and available for any developer as an open source project.

Alternate to V8 engine

Currently NodeJS uses V8 engine for compiling JavaScript source code to machine code instead of interpreting in real time. Now with ChakraCore Microsoft is providing an alternative. Microsoft submitted a pull request to Node.js to work with ChakraCore.

Microsoft implemented a V8 API shim (aka ChakraShim) which takes advantage of ChakraCore runtime hosting APIs (JSRT). Many developers supported this as it is going to be big and awesome stuff. Node.js also welcomed this step that Microsoft coming closer to Node.js. We know Microsoft is an early adopter of Node.js.

"This pull request enables Node.js to optionally use the ChakraCore JavaScript engine," Guarav Seth

Roadmap

The ChakraCore roadmap shows that they are planning to port to Linux, targeting x64 Ubuntu. However, it doesn’t talk about MAC OSX platform. To read more detail please goto URL: https://github.com/Microsoft/ChakraCore/wiki/Roadmap

JSRT (JavaScript Runtime) APIs

JSRT APIs provide a way to embed ChakraCore into applications. It is part of the Core project. Refer architecture diagram.

JSRT

JavaScript engine using the JSRT APIs depends on two key concepts: runtime and execution contexts. It also allows embedding Chakra outside of client-only scenarios also,

  • A runtime represents a complete JavaScript execution environment
  • Execution contexts are tied to a particular runtime and execute code within that runtime.
  • High performance JavaScript engine
  • Support Just-in-time (JIT) compilation of JavaScript
  • Supports JSRT APIs which allows you to embed in your applications

Building ChakraCore

Since it is OSS and available at GitHub you could download source code from GitHub and build using Visual Studio:

  • Clone
  • Open Build\Chakra.Core.sln in Visual Studio

    Build

  • Build Solution

Embedding ChakraCore

It can be embedded via JSRT APIs and Azure DocumentDB was one of the other programs which uses Chakra to provide JavaScript programmability. DocumentDB is NoSQL document oriented database which is built to support JSON & JavaScript. Therefore, it’s good for DocumentDB to leverage Chakra to process JavaScript.

To read more details.

Summary

I am eagerly looking forward to leveraging ChakraCore in Node.js and cross platform applications. I am sure you must be as well. Please share your feedback / comments.

Up Next
    Ebook Download
    View all
    Learn
    View all