Hermes: Open-source JavaScript engine by Facebook

Hermes: Open-source JavaScript engine by Facebook

Just recently, Facebook has released its new JavaScript engine, called Hermes. Hermes is an open source engine with MIT license and has been launched to expedite the start time of native Android applications that are developed using React Native framework.

Hermes was unveiled in front of the world by Marc Horowitz, Facebook software engineer at the Chain React 2-19 conference being held in Portland, Oregon. Hermes is developed for two reasons: to help developers in improving the startup time/performance of applications and to improve the efficiency of applications on cheaper/low-end smart devices.

According to official ReactNative handle on Twitter,

“Facebook has launched an open sourcing Hermes, a small and lightweight JavaScript engine optimized for running React Native on Android”.

The biggest advantage of Hermes is that developers can run their apps on all three mobile platforms by writing same code base. During the demo session of Hermes at the conference, Horowitz showcased how a React Native app without Hermes takes double time to load when compared to app with Hermes. He also mentioned that Hermes cuts the APK size by half and uses less memory of the smartphone.

Why Hermes?

Phones that are on the lower-end have limitations such as memory and time lags, compared to a high-end, expensive smartphones. Hermes is launched to minimize this issue so that users can enjoy their React Native apps without any hindrance. It is anticipated that with Hermes, the downloading time for apps will lower down and memory sharing of the smartphone will become more efficient.

While commenting on the vision behind Hermes, Horowitz said, “As developers we tend to carry the latest flagship devices. Most users around the world don’t. Commonly used Android devices have less memory and less storage than the newest phones and much less than a desktop. This is especially true outside of the United States. Mobile flash is also relatively slow, leading to high I/O latency”.

The three core app attributes that Hermes will improve are: time-to-interact (TTI) – which is the loading time of a mobile app, memory utilization – memory that app utilizes while running, and download size of the app (APK size).

It was also discussed at the conference that Hermes is not created to become a competition for JavaScript engines for browsers, rather Facebook does not plan to go beyond React Native. The reason is that Hermes is made specifically while keeping in mind smart phones applications and thereof it will not help the performance for browser-based scenarios.

How it works?

Instead of loading JavaScript first and then parsing it, Hermes makes use of bytecode pre-compilation. Hermes also uses AOT (ahead-of-time) compilation during the development of mobile app so that bytecode optimization can be used extensively. While typically JavaScript engines use JIT (just in time) compiler to compile code into machine code, Hermes does not use this compiler.

Hermes is compatible with ES6 JavaScript. Currently, there are a few features that are missing from the engine, for instance, support for some languages, local model eval() and statements. This has been done on purpose so that the size of engine can be kept small for now.

According to another spokesperson of Facebook, “Hermes allows for more optimization on mobile since developers control the build stack. For example, we implemented bytecode pre-compilation to improve performance and developed more efficient garbage collection to reduce memory usage”.

Hermes is now available on GitHub for any developer around the world to use and develop apps.

Close Menu