Open Source Insider

Aug 13 2019   8:51AM GMT

Facebook open sources Hermes JavaScript engine

Adrian Bridgwater Adrian Bridgwater Profile: Adrian Bridgwater

Tags:

Hermes is the Greek god of trade, heraldry and commerce… but also the Greek god of thieves and trickery.

Facebook was presumably thinking of Hermes’ more virtuous qualities when it named its JavaScript engine project after the Greek deity.

Hermes was built to make native Android apps built using the React Native network load faster.

React Native provides the Fetch API for networking needs.

Now open sourced by Facebook under an MIT licence, Hermes is supposed to supercharge startup times, drain less memory and result in a smaller overall application code footprint.

Why focus on startup times? 

Because application startup times impact what the tech industry likes to call Time To Interaction or TTO (a measure of the period between an application being launched and the user being able to use it)… and that’s a real make or break factor for software houses that pump out mass market applications.

How does it do it?

Part of the secret sauce in Hermes is its ability to execute what is known as bytecode precompilation.

Bytecode precompilation allows code to be processed employing a technique known as Ahead Of Time (AOT) compilation.

“Commonly, a JavaScript engine will parse the JavaScript source after it is loaded, generating bytecode. This step delays the start of JavaScript execution. To skip this step, Hermes uses an Ahead Of Time compiler which runs as part of the mobile application build process. As a result, more time can be spent optimising the bytecode, so the bytecode is smaller and more efficient. Whole-program optimisations can be performed, such as function deduplication and string table packing,” noted Facebook, in a technical statement.

Facebook itself says that as mobile applications are growing larger and more complex, larger apps using JavaScript frameworks often experience performance issues as developers add features and complexity.

According to a summary press statement, “To increase the performance of Facebook’s apps, we have teams that continuously improve our JavaScript code and platforms. As we analysed performance data, we noticed that the JavaScript engine itself was a significant factor in startup performance and download size. With this data in hand, we knew we had to optimise JavaScript performance in the more constrained environments of a mobile phone compared to a desktop or laptop.” 

Hermes currently targets the ES6 specification and the team intends to keep current with the JavaScript specification as it evolves. 

 

 

 

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: