Reply to “Electron is flash for the desktop“ by Joseph Gentle

If you haven’t read his blogpost on Electron being the Flash of desktop, you should read it now. You can find it here.

In his article, Joseph Gentle criticize Electron apps for having a lot of overhead because they run on top of the Chrome runtime which is known for being a little too comfortable with your computer’s resources, and which Gentle compares to a fully fledged operating system; something which is in many ways true.

While Gentle was unhappy with the amount of disk-space Electron apps use, his main problem was the inane memory usage illustrated with Slack’s usage as an example.

From Joseph Gentle’s blog post

While 1GB is a lot of memory, it’s important, however, to compare Electron apps’ resource usage with similar apps that don’t use Electron.

If we look at Microsoft Word’s memory usage which is rather low compared Slack with its 85 MB with an empty window, and 140MB when a 15 MB document filled with text and images is opened (the document text doesn’t have any special formatting).

As Microsoft Word isn’t based on Electron, these findings seem to support the idea that Electron apps, and specifically apps that use the Chrome runtime do patently use more memory than their counterparts.

If we, however, look at a test application; a simple markdown editor which is built on Electron using only pure Javascript, we see that it’s possible for Electron not to consume a shit-ton (that is an official unit of measure) of memory. You can inspect the source code here.

The test application uses less 80MB when it’s running just an empty window; that is less than Microsoft Word which we just concluded was quite memory efficient compared to similar applications. Of course, Microsoft Word has a lot more features than Textdown, but as Joseph Gentle said in his blogpost: “You can think of slack as a small javascript program running inside another operating system VM (chrome)”, and “To be clear, javascript on the desktop isn’t the problem.”, or in other words the application code is tiny compared to the 15 million uncommented lines in the Chromium project, so the fact that Textdown is a tiny application shouldn’t, according to Joseph Gentle, do much to keep the memory consumption down.

While Textdown doesn’t consume as much memory as similar apps, it uses a sizable chunk of disk space of 110 MB, compared to the mere 30 MB of Sublime Text 3. The overflooding of disk space becomes even more painstakingly apparent when considering that Sublime Text has an ocean of functionality

It should be noted that Joseph Gentle’s article was from late October 2016, and it’s entirely possible that Electron, and Chrome, has improved since then, and is what is causing the low memory usage of my test application. How much it has improved is still unclear as Spotify still eats a healthy 600 MB which is 3 times more than what Gentle found.

Ultimately, I think Gentle is somewhat correct; modern apps take use a lot of memory due to the vast frameworks on which they are built. Sure, the frameworks help developers spit out apps faster, and easier than if they had developed them without the huge frameworks, but it shouldn’t be an excuse for not optimizing applications; which it has increasingly become because memory is cheap, right?

However, Electron and Chrome are not completely to blame. As shown Electron apps can also be memory efficient just as non-Electron apps can eat memory as if it was Google Chrome.

Other large frameworks, and lazy programmers can also steal a system’s resources, so the solution is not to just stop using Electron, but becoming aware of the need for lean and fast applications, and the supercomputer in our pockets is not a permit to stop caring about efficiency.

Consequently, if you install an older operating system on a modern computer, and run some of the applications from that era; the era before applications were called apps, you will (re-)discover how snappy everything is. Let’s aim for a similar performance for the apps we use today. Let’s aim for not having to wait 5 seconds for Microsoft Word to load on a fast SSD. Let’s aim for not letting applications needlessly clog a user’s hard drive.

Addendum: As I have been holding off installing Electron apps such as the Discord client because I don’t like the idea of having yet another Chrome runtime running on my computer, I must admit that most Electron applications are more likely to use a lot of memory and disk space, than applications that don’t ship the entire Chromium runtime.