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.