Tuesday, October 31, 2017

Electron Apps

What Are Electron Apps, and Why Have They Become So Common?


Have you noticed a lot of new desktop applications look pretty much like websites? It’s not your imagination.
From Trello to Slack, from WordPress.com to Github, it’s become increasingly common for so-called desktop applications to bundle a website with a few native features like notifications, file system access, and menus. The most common technology enabling this is called Electron, and it’s used by a few applications you might not even suspect, like chat application Discord and Microsoft’s Visual Studio Code.
Electron makes it easy for developers to release an app simultaneously on Windows, macOS, and Linux, but there are downsides for users. Electron applications are huge, for one thing. Slack, a chat application, takes up 237 MB of hard drive space on my Mac, and memory consumption isn’t low either. What’s taking up all those resources? And why are developers using something so inefficient?

Electron Apps Are Pretty Easy to Make

Desktop applications are hard to make, especially if you want them to be cross-platform. Accessing the file system works differently in Windows than it does in Linux, for example, and notifications work differently on macOS than in Windows. This means anyone who wants to write an application for all three desktop operating systems (or even two of them) needs to re-write a lot of their code when porting from one to another.
Electron “solves” this by offering a single platform that works on all three major desktop operating systems. This means developers can write the code for things like notifications once and expect it to work natively on every operating system. Even better for developers: everything can be built using Javascript, HTML, and CSS—technologies anyone who codes for the web are very familiar with.

Electron Apps Come With Pretty Much All of Chromium

How is this possible? In part because every Electron app bundles a complete web browser: Chromium, the open source version of Google Chrome. This is bundled along with the platform-specific instructions in order to ensure that everything behaves exactly as developers expect on all systems. That’s why the desktop version of Slack takes up over 200MB of hard drive space: most of Chrome is bundled in there.
Every Electron app you run is more or less a full instance of Chrome. As blogger Joseph Gentle pointed out, this is hardly ideal:
You can think of Slack as a small javascript program running inside another operating system VM (chrome), that you have to run in order to essentially chat on IRC. Even if you’ve got the real chrome open, each electron app runs its own, extra copy of the whole VM.
So yeah, there are downsides for users. First of all, every single Electron application you download bundles most of Chromium, and every application you run is executing a good chunk of that code. There’s no sharing of resources here like there is with native applications, meaning Electron apps are going to take up more hard drive space and memory than an application developed with your platform specifically in mind. If performance is something you really care about, you might want to avoid Electron applications.

Wait, So Is Electron Good or Bad?

At this point, computers are so powerful that most users will never even notice how inefficient Electron applications are. In fact, the vast majority have never even heard of Electron. Most of my co-workers hadn’t, and they all use Slack every day. Many were excited to see a desktop version of Trello come out, and again had no idea it was an Electron app.
And these apps really do integrate better with your operating system better than websites. They live in their own window. They offer great keyboard shortcuts, native notifications, and other things you can’t do the same way with just a browser.
And It’s a good bet that applications like Slack, Trello, and WordPress.com wouldn’t bother to offer a desktop version if Electron didn’t exist, focusing instead on mobile and browser versions. So the question isn’t whether Electron is bad; it’s whether Electron applications are better than nothing. I’m willing to say yes, but reasonable people can disagree. (And hey, for those people, there’s always the web version.)

No comments:

Post a Comment