— React Native (@reactnative) July 11, 2019
Facebook software engineer Marc Horowitz unveiled Hermes at the Chain React 2019 conference held yesterday in Portland, Oregon. Hermes is a new tool for developers to primarily improve app startup performance in the same way Facebook does for its apps, and to make apps more efficient on low-end smartphones.
The supposed advantage of Hermes is that developers can target all three mobile platforms with a single code base; but as with any cross-platform framework, there are trade offs in terms of performance, security and flexibility. Hermes is available on GitHub for all developers to use. It has also got its own Twitter account and home page.
In a demo, Horowitz showed that a React Native app with Hermes was fully loaded within half the time the same app without Hermes loaded, or about two seconds faster. Check out the video below:
Horowitz emphasized on the fact that Hermes cuts the APK size (the size of the app file) to half the 41MB of a stock React Native app, and removes a quarter of the app’s memory usage.
In other words, with Hermes developers can get users interacting with an app faster with fewer obstacles like slow download times and constraints caused by multiple apps sharing in a limited memory resources, especially on lower-end phones.
And these are exactly the phones Facebook is aiming at with Hermes, compared to the fancy high-end phones that well-paid developers typically use themselves.
“As developers we tend to carry the latest flagship devices. Most users around the world don’t,” he said. “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.”
“We’re not trying to compete in the browser space or the server space. Hermes could in theory be for those kinds of use cases, that’s never been our goal.”
The Register reports that Facebook has no plan to push Hermes’ beyond React Native to Node.js or to turn it into the foundation of a Facebook-branded browser. This is because it’s optimized for mobile apps and wouldn’t offer advantages over other engines in other usage scenarios.
The reason Hermes exists, as per Facebook, is to make React Native better. “Hermes allows for more optimization on mobile since developers control the build stack,” said a Facebook spokesperson in an email to The Register. “For example, we implemented bytecode precompilation to improve performance and developed more efficient garbage collection to reduce memory usage.”
In a discussion on Hacker News, Microsoft developer Andrew Coates claims that internal testing of Hermes and React Native in conjunction with Microsoft Office for Android shows TTI using Hermes at 1.1s, compared to 1.4s for V8, and with 21.5MB runtime memory impact, compared to 30MB with V8.
Facebook’s spokesperson also said to The Register that they are planning to publish benchmark figures in the next week to support its performance claims.