There are several applications that many of us use daily in our particular office space. One of them is probably Google Chrome, which according to NetMarketShare is the most widely used browser in the world. What we did not know is that we may have it installed more than once, and totally opaque to the user.
At least that’s what developer Joseph Gentle revealed on his blog. Apparently, every time we run programs like Slack or Spotify, what we do is run full instances of Chromium, with the consumption of resources that all that entails.
The researches of this developer began when he realized the high consumption of Slack resources. A consumption that, according to the same counted, would not have had notion of not being because the fans of his laptop began to work at a greater speed. Considering that normally consumes 5% in idle mode, the programmer had no way of knowing what he was doing.
All this the developer reduces to that this program is not a native application to use.
The “fault of all” has Electron
Gentle blames everything on Electron. Why? Because, in a few words, it serves to “package” a web so that it can be used as a desktop application. That is, take the HTML, CSS and JavaScript code and package them together with Chromium and Node code.
According to the developer, using this technique is using, along with the code of the web, 99% of Chromium code that is executed in a completely opaque way to the user. In this sense, Chromium works like a virtual machine, which serves as host to Slack’s native code lines. In the words of Joseph Gentle:
You can think of Slack as a small JavaScript program that runs inside the virtual machine of another operating system (Chrome), which you have to run to essentially chat using IRC.
And this is not all, because if you have the Chrome browser open, each desktop app packaged using Electron executes its own copy of the entire “virtual machine”, consuming many resources and emptying batteries more quickly on portable computers.
This large battery consumption should be due to the way in which modern computers manage energy: they go out when there is no scheduled task. Now, when there are programs that execute a small percentage of your CPU constantly is a nightmare for energy conservation.
Basically, what they do is to get the processor into a constant process of work and hibernation , which means that the batteries run out much more quickly.
The recipe of Joseph Gentle
For Gentle everything is reduced to a very basic premise: say no to Electron. Instead, the dev proposes to use React Native as an alternative to package web applications in a similar way, without the need to distribute a copy of Google Chrome with each program.
However, we must bear in mind that, as can be seen in the actual documentationof React Native, this alternative proposed by Joseph Gentle is intended for mobile platforms. It can also be used to package webapps for desktop, there is even a GitHub repository dedicated to macOS, but for now there seems to be nothing similar for other systems.
For Gentle it is also noteworthy that many developers use Slack to communicate with their work groups, without knowing how much they demand from the teams they run on. According to this programmer, it is vital to learn to measure the behavior of the software and have full knowledge of it before launching to improve it.