Facebook released the source code of the Hermes JavaScript engine

Hermes

Facebook has opened the source code for the lightweight Hermes JavaScript engine, optimized to run React Native framework based applications on the Android platform.

The Facebook Software Engineer Marc Horowitz revealed the new JavaScript engine at the 2019 Chain React conference in Portland, Oregon. Hermes is a new developer tool that focuses on improving app startup performance in the same way Facebook already does for its apps and making apps more effective on entry-level smartphones.

About Hermes

Hermes support is built into React Native as of today's version 0.60.2. The project is recognized for solving problems with long startup times for native JavaScript applications and significant resource consumption. The code is written in C ++ and distributed under the MIT license.

Of the advantages of using Hermes, there is a reduction in the start time of the application, a decrease in memory consumption and a decrease in the size of the application.

Acceleration of applications launch is achieved by using precompilation in a bytecode compact and efficient at the compilation stage.

To run the application directly, a virtual machine is used with the SemiSpace garbage collector developed as part of the project. With V8, the longest are the steps to parse the source code and compile it on the fly.

The Hermes engine takes these stages to the compilation stage and allows applications to be delivered in the form of optimized byte code.

JavaScript processing is divided into several stages. Initially, the source code is parsed and the intermediate code representation (Hermes IR) is generated, based on the SSA representation (Static Unique Assignment).

In addition, the intermediate representation is processed in the optimizer, which uses proactive static optimization techniques to convert the primary intermediate code to a more efficient intermediate representation, while preserving the semantics of the original program.

Finally in the last stage, the byte code for the registered virtual machine is generated.

In a demo, Marc Horowitz showed that a React Native application with Hermes it was fully loaded about two seconds faster than the same application loaded without Hermes.

Marc Horowitz made sure Hermes also reduced the size of the APK to the middle of a React Native stored app's 41MB and eliminated a quarter of the app's memory usage.

In other words, with Hermes, developers can get users to interact more quickly with an application with fewer obstacles, such as slow download times and restrictions caused by multiple applications sharing limited memory resources, such as: Especially on level phones input.

The engine supports part of the ECMAScript 2015 JavaScript standard (full support is the end goal) and is compatible with most existing React Native applications. In Hermes, it was decided not to support local casting of eval (), "with" expressions, reflections (Reflect and Proxy), Intl API API and some flags in RegExp.

To enable Hermes in the React Native application, simply add the "enableHermes: true" option to the project. It is also possible to compile Hermes in the CLI interface mode, which allows you to execute arbitrary JavaScript files from the command line.

At the same time, Facebook does not plan to adapt Hermes for Node.js and other solutions, focusing only on mobile applications (compiling AOT instead of JIT is more optimal in the context of React Native based mobile apps).

Microsoft conducted preliminary performance tests and showed that when using Hermes, the Microsoft Office for Android application is available to work in 1.1 seconds.

After launch and it consumes 21.5MB of RAM, while using the V8 engine, 1.4 seconds are spent at launch, and memory consumption is 30MB.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.