Top Related Projects
ChakraCore is an open source Javascript engine with a C API.
The official mirror of the V8 Git repository
Node.js JavaScript runtime ✨🐢🚀✨
A modern runtime for JavaScript and TypeScript.
Ultra-lightweight JavaScript engine for the Internet of Things.
QuickJS是一个小型并且可嵌入的Javascript引擎,它支持ES2020规范,包括模块,异步生成器和代理器。
Quick Overview
Hermes is an open-source JavaScript engine optimized for running React Native on Android. It's designed to improve app performance, reduce memory usage, and decrease app size. Hermes focuses on efficient bytecode precompilation and execution.
Pros
- Faster app start-up times and improved runtime performance
- Reduced memory usage and smaller app size
- Optimized for mobile environments, especially Android
- Seamless integration with React Native
Cons
- Limited support for some JavaScript features (e.g., eval())
- May not be suitable for all types of JavaScript applications
- Potential compatibility issues with some third-party libraries
- Learning curve for developers unfamiliar with the engine
Code Examples
Since Hermes is a JavaScript engine and not a code library, there are no direct code examples to provide. However, developers can use Hermes with React Native applications.
Getting Started
To use Hermes with a React Native project:
- Ensure you have React Native 0.60.4 or later installed.
- Enable Hermes in your project by editing
android/app/build.gradle
:
def enableHermes = project.ext.react.get("enableHermes", true);
- Clean and rebuild your project:
cd android
./gradlew clean
cd ..
npx react-native run-android
For more detailed instructions and advanced configuration, refer to the official Hermes documentation and React Native guides.
Competitor Comparisons
ChakraCore is an open source Javascript engine with a C API.
Pros of ChakraCore
- More mature and established project with a longer history
- Broader language support, including full ECMAScript 2015 (ES6) compatibility
- Better performance for complex JavaScript applications
Cons of ChakraCore
- Larger footprint and higher memory usage
- Slower startup time, especially for smaller applications
- Less optimized for mobile environments
Code Comparison
ChakraCore:
const engine = new ChakraCore.JsRuntime();
const context = engine.createContext();
const result = context.runScript('2 + 2');
console.log(result); // Output: 4
Hermes:
const hermes = require('hermes-engine');
const vm = new hermes.VM();
const result = vm.evaluate('2 + 2');
console.log(result); // Output: 4
Both engines provide similar functionality for running JavaScript code, but ChakraCore offers a more comprehensive API for advanced use cases. Hermes, on the other hand, focuses on simplicity and efficiency for mobile environments.
ChakraCore is better suited for complex web applications and desktop environments, while Hermes excels in mobile app development, particularly for React Native projects. The choice between the two depends on the specific requirements of your project, considering factors such as performance needs, target platform, and development ecosystem.
The official mirror of the V8 Git repository
Pros of v8
- Widely adopted and battle-tested in major browsers like Chrome
- Extensive optimization techniques for high-performance JavaScript execution
- Supports a broader range of JavaScript features and ECMAScript standards
Cons of v8
- Larger memory footprint, which can be challenging for resource-constrained devices
- More complex codebase, potentially making it harder to customize for specific use cases
- Slower startup time compared to Hermes, especially on mobile devices
Code Comparison
v8 (C++):
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();
Hermes (C++):
jsi::Runtime &runtime = hermes::makeHermesRuntime();
jsi::Value result = runtime.evaluateJavaScript(
std::make_shared<jsi::StringBuffer>("'Hello' + ', World!'"),
"inline");
Both v8 and Hermes are JavaScript engines, but they have different design goals and trade-offs. v8 focuses on high performance for general-purpose JavaScript execution, while Hermes is optimized for React Native mobile applications, prioritizing fast startup and lower memory usage.
Node.js JavaScript runtime ✨🐢🚀✨
Pros of Node.js
- Larger ecosystem with more packages and community support
- Broader application range, suitable for various server-side and desktop applications
- More mature and stable, with longer history and extensive production use
Cons of Node.js
- Larger runtime size, which can be less suitable for mobile or resource-constrained environments
- Generally slower startup time compared to Hermes
- Not optimized specifically for React Native applications
Code Comparison
Node.js:
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
});
server.listen(3000);
Hermes:
// Hermes is primarily used in React Native, so a direct comparison is not applicable.
// However, here's a simple React Native component using Hermes:
import React from 'react';
import { Text, View } from 'react-native';
const HelloWorld = () => (
<View>
<Text>Hello World</Text>
</View>
);
Note: Hermes is specifically designed as a JavaScript engine for React Native, while Node.js is a general-purpose JavaScript runtime. The code comparison showcases their different use cases rather than direct feature comparisons.
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
- Supports ES modules natively and has a built-in package manager
Cons of Deno
- Smaller ecosystem compared to Node.js, which Hermes is designed to work with
- Learning curve for developers familiar with Node.js
- Limited compatibility with existing Node.js packages
Code Comparison
Deno:
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
serve((req) => new Response("Hello, World!"));
Hermes (JavaScript runtime, typically used within React Native):
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, World!');
}).listen(8080);
Summary
Deno and Hermes serve different purposes. Deno is a secure runtime for JavaScript and TypeScript, focusing on modern web standards. Hermes is a JavaScript engine optimized for React Native, prioritizing fast startup and low memory usage on mobile devices. While Deno offers built-in TypeScript support and security features, Hermes provides better performance for mobile applications within the React Native ecosystem.
Ultra-lightweight JavaScript engine for the Internet of Things.
Pros of JerryScript
- Extremely lightweight and suitable for resource-constrained devices
- Highly portable, supporting a wide range of platforms and architectures
- Compliant with ECMAScript 5.1 standard
Cons of JerryScript
- Limited support for modern JavaScript features
- Smaller community and ecosystem compared to Hermes
- Less optimized for mobile app performance
Code Comparison
JerryScript:
#include "jerryscript.h"
int main (void)
{
const jerry_char_t script[] = "print('Hello, World!');";
jerry_run_simple(script, sizeof(script) - 1, JERRY_INIT_EMPTY);
return 0;
}
Hermes:
#include "hermes/hermes.h"
int main() {
hermes::vm::RuntimeConfig conf;
auto runtime = hermes::makeHermesRuntime(conf);
runtime->runScript("print('Hello, World!');");
return 0;
}
Both JerryScript and Hermes are JavaScript engines designed for embedded systems and mobile applications. JerryScript focuses on being ultra-lightweight and portable, making it ideal for IoT devices and resource-constrained environments. Hermes, developed by Facebook, is optimized for React Native mobile apps, offering better performance and smaller bundle sizes.
While JerryScript supports a broader range of platforms, Hermes provides better support for modern JavaScript features and is more tailored for mobile app development. The code examples demonstrate the simplicity of running JavaScript in both engines, with JerryScript using a C API and Hermes using a C++ API.
QuickJS是一个小型并且可嵌入的Javascript引擎,它支持ES2020规范,包括模块,异步生成器和代理器。
Pros of QuickJS
- Smaller footprint and faster startup time
- Easier to embed in other applications
- More compliant with ECMAScript standards
Cons of QuickJS
- Less optimized for mobile environments
- Smaller community and ecosystem
- Fewer performance optimizations for long-running applications
Code Comparison
QuickJS:
JSRuntime *rt = JS_NewRuntime();
JSContext *ctx = JS_NewContext(rt);
const char *code = "console.log('Hello, World!');";
JS_Eval(ctx, code, strlen(code), "<input>", JS_EVAL_TYPE_GLOBAL);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
Hermes:
jsi::Runtime *runtime = hermes::makeHermesRuntime();
jsi::Value result = runtime->evaluateJavaScript(
std::make_unique<jsi::StringBuffer>("console.log('Hello, World!');"),
"<input>");
delete runtime;
Key Differences
- QuickJS is written in C, while Hermes is primarily C++
- Hermes focuses on optimizing for React Native, while QuickJS aims for general-purpose use
- QuickJS provides a more complete JavaScript environment, including a built-in compiler
- Hermes emphasizes bytecode precompilation and optimized memory usage for mobile devices
Both engines serve different purposes, with QuickJS being more suitable for embedded systems and Hermes excelling in mobile app performance.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Hermes JS Engine
Hermes is a JavaScript engine optimized for fast start-up of React Native apps. It features ahead-of-time static optimization and compact bytecode.
If you're only interested in using pre-built Hermes in a new or existing React Native app, you do not need to follow this guide or have direct access to the Hermes source. Instead, just follow these instructions to enable Hermes.
Noted that each Hermes release is aimed at a specific RN version. The rule of thumb is to always follow Hermes releases strictly. Version mismatch can result in instant crash of your apps in the worst case scenario.
If you want to know how to build and hack on Hermes directly, and/or integrate Hermes built from source into a React Native app then read on.
The instructions here very briefly cover steps to build the Hermes CLI. They assume you have typical native development tools setup for your OS, and support for cmake and Ninja. For more details of required dependencies, building Hermes with different options, etc. follow these links instead:
To build a local debug version of the Hermes CLI tools the following steps should get you started on macOS/Linux:
mkdir hermes_workingdir
cd hermes_workingdir
git clone https://github.com/facebook/hermes.git
cmake -S hermes -B build -G Ninja
cmake --build ./build
Or if you're using Windows, the following should get you going in a Git Bash shell:
mkdir hermes_workingdir
cd hermes_workingdir
git -c core.autocrlf=false clone https://github.com/facebook/hermes.git
cmake -S hermes -B build -G 'Visual Studio 16 2019' -A x64
cmake --build ./build
You will now be in a directory with the output of building Hermes into CLI tools. From here you can run a piece of JavaScript as follows:
echo "'use strict'; function hello() { print('Hello World'); } hello();" | ./bin/hermes
Contributing
The main purpose of this repository is to continue to evolve Hermes, making it faster and more efficient. We are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving Hermes.
Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.
Contributing Guide
Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Hermes.
License
Hermes is MIT licensed.
Top Related Projects
ChakraCore is an open source Javascript engine with a C API.
The official mirror of the V8 Git repository
Node.js JavaScript runtime ✨🐢🚀✨
A modern runtime for JavaScript and TypeScript.
Ultra-lightweight JavaScript engine for the Internet of Things.
QuickJS是一个小型并且可嵌入的Javascript引擎,它支持ES2020规范,包括模块,异步生成器和代理器。
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot