Convert Figma logo to code with AI

chakra-core logoChakraCore

ChakraCore is an open source Javascript engine with a C API.

9,094
1,193
9,094
602

Top Related Projects

ChakraCore is an open source Javascript engine with a C API.

23,181

The official mirror of the V8 Git repository

106,466

Node.js JavaScript runtime ✨🐢🚀✨

93,919

A modern runtime for JavaScript and TypeScript.

Quick Overview

ChakraCore is the core JavaScript engine that powers Microsoft Edge. It's a standalone JavaScript engine that can be embedded in other applications, offering high performance and cross-platform capabilities. ChakraCore is open-source and maintained by Microsoft.

Pros

  • High performance JavaScript execution
  • Cross-platform support (Windows, Linux, macOS)
  • Supports modern JavaScript features and standards
  • Embeddable in various applications and environments

Cons

  • Less community support compared to more popular engines like V8
  • Documentation could be more comprehensive
  • Limited ecosystem of tools and libraries specifically built for ChakraCore
  • Development pace has slowed down in recent years

Code Examples

  1. Embedding ChakraCore in a C++ application:
#include <ChakraCore.h>

// Initialize ChakraCore
JsRuntimeHandle runtime;
JsCreateRuntime(JsRuntimeAttributeNone, nullptr, &runtime);

JsContextRef context;
JsCreateContext(runtime, &context);
JsSetCurrentContext(context);

// Execute JavaScript code
JsValueRef result;
JsRunScript(L"5 + 7", JS_SOURCE_CONTEXT_NONE, L"", &result);

// Get the result
int intResult;
JsNumberToInt(result, &intResult);
printf("Result: %d\n", intResult);

// Clean up
JsSetCurrentContext(JS_INVALID_REFERENCE);
JsDisposeRuntime(runtime);
  1. Using ChakraCore's JSRT API to create and manipulate objects:
JsValueRef globalObject;
JsGetGlobalObject(&globalObject);

JsValueRef propertyName;
JsCreateString("myProperty", strlen("myProperty"), &propertyName);

JsValueRef propertyValue;
JsIntToNumber(42, &propertyValue);

JsSetProperty(globalObject, propertyName, propertyValue, true);
  1. Calling a JavaScript function from C++:
// Assume we have a JavaScript function defined as:
// function add(a, b) { return a + b; }

JsValueRef function;
JsGetGlobalObject(&globalObject);
JsGetProperty(globalObject, JsCreateString("add", strlen("add"), &propertyName), &function);

JsValueRef args[2];
JsIntToNumber(5, &args[0]);
JsIntToNumber(7, &args[1]);

JsValueRef result;
JsCallFunction(function, args, 2, &result);

int intResult;
JsNumberToInt(result, &intResult);
printf("Result: %d\n", intResult);

Getting Started

To get started with ChakraCore:

  1. Clone the repository:

    git clone https://github.com/chakra-core/ChakraCore.git
    
  2. Build ChakraCore (on Windows with Visual Studio):

    cd ChakraCore
    msbuild /m /p:Platform=x64 /p:Configuration=Release Build\Chakra.Core.sln
    
  3. Include ChakraCore in your project and start using the JSRT API as shown in the code examples above.

For more detailed instructions and platform-specific build steps, refer to the official ChakraCore documentation.

Competitor Comparisons

ChakraCore is an open source Javascript engine with a C API.

Pros of ChakraCore

  • Open-source JavaScript engine with cross-platform support
  • High performance and efficient memory usage
  • Supports modern JavaScript features and ECMAScript standards

Cons of ChakraCore

  • Limited community support and contributions
  • Fewer integrations with third-party tools compared to other engines
  • Less frequent updates and maintenance

Code Comparison

ChakraCore:

JsRuntimeHandle runtime;
JsContextRef context;
JsCreateRuntime(JsRuntimeAttributeNone, nullptr, &runtime);
JsCreateContext(runtime, &context);
JsSetCurrentContext(context);

As the comparison is between the same repository (ChakraCore), there is no code difference to highlight. The code snippet above demonstrates the basic setup for creating a runtime and context in ChakraCore.

Summary

ChakraCore is a powerful JavaScript engine with cross-platform support and high performance. However, it faces challenges in terms of community engagement and ongoing development. The repository serves as both the subject and comparison point in this case, making it difficult to draw distinctions between them.

23,181

The official mirror of the V8 Git repository

Pros of v8

  • Wider adoption and community support, used in Chrome and Node.js
  • Generally faster performance, especially for complex JavaScript applications
  • More frequent updates and active development

Cons of v8

  • Larger memory footprint, which can be an issue for resource-constrained devices
  • Steeper learning curve for contributors due to its complexity
  • Less modular architecture compared to ChakraCore

Code Comparison

V8 (JavaScript execution):

Local<Context> context = Context::New(isolate);
Context::Scope context_scope(context);
Local<String> source = String::NewFromUtf8(isolate, "'Hello' + ', World!'");
Local<Script> script = Script::Compile(context, source).ToLocalChecked();
Local<Value> result = script->Run(context).ToLocalChecked();

ChakraCore (JavaScript execution):

JsRuntimeHandle runtime;
JsContextRef context;
JsCreateRuntime(JsRuntimeAttributeNone, nullptr, &runtime);
JsCreateContext(runtime, &context);
JsSetCurrentContext(context);
JsRunScript(L"'Hello' + ', World!'", JS_SOURCE_CONTEXT_NONE, L"", nullptr);

Both engines provide similar functionality for executing JavaScript code, but V8's API is more verbose and offers finer control over the execution environment. ChakraCore's API is simpler and more straightforward for basic use cases.

106,466

Node.js JavaScript runtime ✨🐢🚀✨

Pros of Node.js

  • Larger ecosystem with more packages and community support
  • Cross-platform compatibility and wider range of use cases
  • Better performance for I/O-intensive operations

Cons of Node.js

  • Larger codebase and potentially more complex
  • Less focused on JavaScript engine optimization
  • May have higher memory usage for certain tasks

Code Comparison

ChakraCore (JavaScript engine focus):

JsCreateRuntime(JsRuntimeAttributeNone, nullptr, &runtime);
JsCreateContext(runtime, &context);
JsSetCurrentContext(context);
JsRunScript(L"var x = 1 + 2;", JS_SOURCE_CONTEXT_NONE, L"", nullptr);

Node.js (Full runtime environment):

const http = require('http');
const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World\n');
});
server.listen(8080);

ChakraCore focuses on JavaScript execution, while Node.js provides a complete runtime environment with built-in modules for various tasks. Node.js has a larger ecosystem and broader application, but ChakraCore may offer more specialized JavaScript engine optimizations.

93,919

A modern runtime for JavaScript and TypeScript.

Pros of Deno

  • Built-in TypeScript support without additional configuration
  • Secure by default, with explicit permissions for file, network, and environment access
  • Includes a standard library and built-in tooling (e.g., formatter, linter)

Cons of Deno

  • Smaller ecosystem compared to Node.js, which ChakraCore supports
  • Limited compatibility with existing Node.js packages and modules
  • Steeper learning curve for developers familiar with Node.js

Code Comparison

Deno:

import { serve } from "https://deno.land/std@0.140.0/http/server.ts";

serve(() => new Response("Hello, World!"));

ChakraCore (via Node.js):

const http = require('http');

http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello, World!');
}).listen(8080);

Key Differences

  • Deno focuses on modern JavaScript/TypeScript development with built-in security features
  • ChakraCore is a JavaScript engine that can be embedded in various applications
  • Deno aims to improve upon Node.js, while ChakraCore provides a foundation for JavaScript execution
  • Deno has a more opinionated approach to module management and security
  • ChakraCore offers broader compatibility with existing JavaScript ecosystems

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ChakraCore

Discord Chat Licensed under the MIT License PR's Welcome

ChakraCore is a JavaScript engine with a C API you can use to add support for JavaScript to any C or C compatible project. It can be compiled for x64 processors on Linux macOS and Windows. And x86 and ARM for Windows only. It is a future goal to support x86 and ARM processors on Linux and ARM on macOS.

Future of ChakraCore

As you may have heard Microsoft Edge no longer uses Chakra. Microsoft will continue to provide security updates for ChakraCore 1.11 until 9th March 2021 but do not intend to support it after that.

ChakraCore is planned to continue as a community project targeted primarily at embedded use cases. We hope to produce future releases with new features and enhancements to support such use cases. We also would like to invite any interested parties to be involved in this project. For further details please see the following draft planning documents: Overall plan Version 1.12 plan

Also see discussion in issue #6384

If you'd like to contact the community team please either open an issue or join the Discord chat linked above.

Security

If you believe you have found a security issue in ChakraCore 1.11, please share it with Microsoft privately following the guidance at the Microsoft Security TechCenter. Reporting it via this channel helps minimize risk to projects built with ChakraCore.

If you find a security issue in the Master branch of Chakracore but not in 1.11 please join our Discord server and private message one of the Core team members.

Documentation

Building ChakraCore

You can build ChakraCore on Windows 7 SP1 or above, and Windows Server 2008 R2 or above, with either Visual Studio 2015 or 2017 with C++ support installed. Once you have Visual Studio installed:

  • Clone ChakraCore through git clone https://github.com/Microsoft/ChakraCore.git
  • Open Build\Chakra.Core.sln in Visual Studio
  • Build Solution

On macOS you can build ChakraCore with the xcode command line tools and cmake. On Linux you can build ChakraCore with cmake and ninja.

More details in Building ChakraCore.

Alternatively, see Getting ChakraCore binaries for pre-built ChakraCore binaries.

Using ChakraCore

Once built, you have a few options for how you can use ChakraCore:

  • The most basic is to test the engine is running correctly with the application ch.exe (ch on linux or macOS). This app is a lightweight host of ChakraCore that you can use to run small applications. After building, you can find this binary in:
    • Windows: Build\VcBuild\bin\${platform}_${configuration} (e.g. Build\VcBuild\bin\x64_debug)
    • macOS/Linux: buildFolder/config/ch (e.g. out/Release/ch)
  • You can embed ChakraCore in your applications - see documentation and samples.

A note about using ChakraCore: ChakraCore is a JavaScript engine, it does not include the external APIs that are provided by a Web Browser or Node.js. For example, DOM APIs like document.write() are additional APIs that are not provided by ChakraCore, when embedding ChakraCore in an application you will need to implement your own input and output APIs. For debugging, in ch you can use print() to put text to the terminal.

Alternatively, if you are using the vcpkg dependency manager you can download and install ChakraCore with CMake integration in a single command:

  • vcpkg install chakracore

Contribute

Contributions to ChakraCore are welcome. Here is how you can contribute to ChakraCore:

Please refer to Contribution Guidelines for more details.

License

Code licensed under the MIT License.

Contact Us

If you have questions about ChakraCore, or you would like to reach out to us about an issue you're having or for development advice as you work on a ChakraCore issue, you can reach us as follows:

  • Open an issue and prefix the issue title with [Question]. See Question tag for already-opened questions.
  • Discuss ChakraCore with the team and the community via the Discord link above