Tech obesity

Posted by kdow on Apr 12, 2017 10:56:43 AM


For work I use a brand new 13-inch MacBook Pro with Touch Bar. It has a 3.1GHz processor, 16GB of RAM and a 500GB SDD. No, it’s not the best laptop ever built. It’s not even as good as my 15-inch MacBook Pro that I use at home. But for what I need in work (a text editor, excel, keynote, browser, Slack and some VOIP stuff) it’s awash with specifications that’ll never hit their theoretical limits.

Right now there’s only a few apps open on my laptop. Chrome, Safari (for personal stuff like this exact post), Spotify, Slack & Excel. For Chrome & Safari I have fairly maniacal tab management habits.

However, Spotify is taking up 5% of my CPU time right now — and that regularly spikes north of 10–15% even when sitting idle. Slack has been okay for me (not bad enough to cause me to have to check in with it regularly for CPU time or memory) but in the office (where most people use MacBook Airs with 8GB of memory) it’s been common to hear fans whirring obnoxiously in lieu of a mandatory restart.

In the case of Spotify & Slack (music streaming & text chatroom apps respectively) the reason they take up so much memory and CPU time is that they’re built on a technology stack called Electron. Other apps using the framework include Atom (the text editor for devs) Hyper terminal, Visual Studio Code & more.

Electron is basically built on top of Chromium, which means each app — no matter what their function — comes with an ocean of dependencies below them. The app, in essence, is the tip of the iceberg. Chrome’s surface area in terms of lines of code & size is about the same as the Linux kernel. Chrome is actually an OS by any standard. This means Spotify, which is built to stream music, has an oceanic amount of code underneath it so that it can run, which is why CPU spikes & memory leaks are abundant within it.

The value of Electron to devs is that it can run the same code base on multiple devices. So there’s no need to roll out development time for the iOS, Android & desktop apps separately. It’s hyper efficient from that perspective. Also it uses web tech like HTML, CSS & JS which is also incredibly efficient, easy to learn and has an abundance of talent for which you can recruit for.

The problem is that Electron has become something akin to Flash. Flash was useful but had a bad reputation because it was being used for apps that really didn’t need to deploy Flash at all, causing CPU spikes & memory bandwidth issues. Moreover, each app uses a unique instance of Chrome, rather than pulling from one big resource to make things more efficient. So in essence with a text chat app, music streaming app & text editor open alongside your actual web browser, you have four instances of the iceberg live on your computer. Hogging CPU & memory space, as well as expensive hard drive space!

There are plenty of modern alternatives that take up less resources and probably perform better. React Native springs to mind, as does Swift or Titanium.

My point is that we’re veering very close to the sun on this stuff. Developers need to be careful what choices they make in technology stacks. I’ve no doubt that in the coming years Slack & Spotify will need to rebuild from the ground up because running instances of Chrome becomes too cumbersome for the user experience. There’s no need to use Electron’s stack for these apps at all.