Facebook released Hermes, an open source JavaScript engine to run React Native apps on Android

Facebook released Hermes, an open source JavaScript engine to run React Native apps on Android
April 9, 2020 2 Comments Business, City, Education, Entertainment, Jobs & Education, Other, Programming, Social Media, Technology Priya Saha

Yesterday Facebook released a new JavaScript engine called Hermes under an open source MIT license. According to Facebook, this new engine will speed up start times for native Android apps built with React Native framework.

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.

Also Read  How to Find the Best Cleaning services provider in Vancouver, Canada.

“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.”

It’s not every day a new JavaScript engine is born, but while there are plenty such engines available for browsers, like Google’s V8, Mozilla’s SpiderMonkey, Microsoft’s Chakra, Horowitz notes Hermes is not aimed at browsers or, for example, how Node.js on the server side.

“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.

Hermes tries to be efficient through bytecode precompilation – rather than loading JavaScript and then parsing it. Hermes employs ahead-of-time (AOT) compilation during the mobile app build process to allow for more extensive bytecode optimization. Along similar lines, the Fuchsia Dart compiler for iOS is an AOT compiler.

There are other ways to squeeze more performance out of JavaScript. The V8 engine, for example, offers a capability called custom snapshots. However, this is a bit more technically demanding than using Hermes.

Hermes also abandons the just in time (JIT) compiler used by other JavaScript engines to compile frequently interpreted code into machine code. In the context of React Native, the JIT doesn’t do that much to ease mobile app workloads.

Also Read  What is CBD Chocolate and Why You Need It

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.

Hermes is mostly compatible with ES6 JavaScript. To keep the engine small, support for some language features is missing, like with statements and local mode eval().

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.

Tags
About The Author
Priya Saha I am content writer at LoogleBiz -A Large Local Business Directory with over 5 years' experience in creating high-quality content for a range of clients. Writing clear marketing copy to awareness about products/services, Preparing well-structured drafts using Content Management Systems, Researching industry-related topics (combining online sources, interviews and studies), include conducting thorough research on industry-related topics, generating ideas for new content types and proofreading articles before publication. #Some qualities that I have - *Excellent command over English language. *Basic analytical skills. *An eye for details. *Ability to meet deadlines. *Ability to develop innovative and engaging content. *Being able to deliver under deadlines. *Excellent writing and editing skills in English *Good command over Microsoft Office tools like Word doc, Powerpoint etc.
Leave Comment
  1. 1

    Sunil Kumar

    Good read. Thanks for the data. It helps us. We only have several comments per post and were evaluating the impact on metrics. Doesn’t seem to be any. Thanks once again.. https://bloggerspassion.com/

  2. 1

    Aarti Biswas

    Good article, keep going on.. https://firstsiteguide.com/