Medium: Electron is Cancer

https://medium.com/@caspervonb/electron-is-cancer-b066108e6c32

I entirely agree on my first read-through…

I am constantly amazed at how electron apps like Discord or Gitter.im or IRCCloud (or especially Atom/VSCode) each take more memory than my entire, full-intellisense development environments, as well as they have this nasty habit of lagging my system until I start killing (often with kill -9 because they stop responding) and restarting them.

EDIT: A side note, I really hate Medium, wtf… pay to see trivial articles?

EDIT2: It was public, now behind this weird medium annoyance, here is the copy/paste (sans the formatting obviously):

Electron is Cancer
You Wouldn’t Want to Spread Cancer, Would You?

A little while ago I posted some benchmarks comparing Nano, Vim and Sublime against Atom and Visual Studio Code, the latter two being Electron based applications and the results were somewhat expected. Electron applications are fat bastards that like to munch on your memory and I’m definitively not the first one to make note of that.
In that article however I went fairly soft on Electron and did not really dig into it, just ran through the numbers I got on my daily carry laptop.
However the feedback for that article was overwhelmingly along the lines of something like the following;
Well, it works fine on my machine, and I only have 32 gigabytes of ram.

  • Silicon Valley Developer, 2017
    If that’s you, well then that’s good for you, but just because something performs “well enough” on your machine doesn’t mean there are not any performance problems. You are not your end-users, and you if you are a developer most likely do not run average hardware.
    Performance Still Matters
    To me it seems a little bit absurd to have to even say this, perhaps it might even be a little condescending but it really seems that the more processing power we get the more sloppy developers are getting with writing good code.
    So here it goes, performance matters, just because your process could hog the processor and memory does not mean you should. This is especially true if your application is one that has native equivalents, like a text chat client would have a minimal footprint, there really isn’t any excuse for being this kind of slacker.
    An operating system is a cooperative environment, just as I won’t go back on a webpage that is intrusive and annoying I will not use an application that is intrusive and annoying.
    A few years ago we could do amazing things with a few hertz of processing power and a few megabytes of memory, these days we get to use it all so we can render a blinking cursor icon!
    Electron Is Easy
    In one form or another, the argument that Electron improves productivity comes up a lot.
    Electron is so great, we did not have to hire new people we can just use your web designers that we already have in-house and it is so easy!
  • Someone Actually Said That
    Okay, sure having a plumber cut out a square wheel from a plank is also a lot easier to do than having a woodworker carve a perfectly round wooden wheel, but it is gonna be one hell of a bumpy ride, and square wheels are actually fine, right?
    To me, this seems more like a symptom of the general performance characteristics we see, if the only cache the developer knows about is function memoization or http caching then well you can’t really expect that application to stay within any sort of cache lines.
    Bottom line; as an end user I really could not care less about how easy it was for you to make the application, if it is not working properly it is not working properly, being slow on today’s super fast hardware is a bug.
    Let me just re-iterate that, as an end-user I do not give two rats asses about how you wrote your application, you can make excuses for the tools you used for it and praise it all day but slow is still slow and bad is still bad.
    Electron Is Not Native
    I tend to call Electron applications web pages whenever I talk about them, which in turn tends to piss off a lot of web developers but really that’s all they are. There is nothing desktop like about Electron applications, they always feel out of place, even the simplest elements like the native menu bar is not available.
    They just don’t integrate with the operating system the way a native application is expected to do, is this not the reason that why we vowed to kill Flash in the first place?
    Even stranger, lately there have been projects popping up that compile from C# to Electron. Yes, let that sink in, from native code (C# can be AOT compiled to native, has tons of GUI frameworks) to JavaScript, so that it can run as a webpage in the Electron browser.
    I do not even…
7 Likes

I love the idea of Electron. Giving simple folks like me the ability to make a desktop app using the same tools I use to build other things is an awesome thing.

But good lord, the implementation really is harsh on my computer. I have last year’s Dell XPS 13 with 8 gigs of ram and just having VS Code (which is the best electron app I’ve used in terms of memory consumption), Chrome, and Slack open ends up chomping through almost every bit of ram I have.

Electron as an idea is awesome. I don’t think it really works in practice though.

Edit - relevant tweet: https://twitter.com/iamdevloper/status/926458505355235328

7 Likes

This sums up my thoughts. ^.^

3 Likes

Join Medium to read this story

Yeeaah forget it.

Maybe we need a new Electron-like framework based on Firefox Quantum? Since people really want to build apps this way but Chromium is a bloated monster.

3 Likes

Firefox Quantum would be a lot more performant base for sure, but it still would not be ‘small’ in most cases. The DOM renderer, though fast, is not lightweight and will gobble memory (though not as bad as chrome by far), and if you use javascript VM instead of something a bit more native then, well, again… >.>

4 Likes

Don’t hate the platform. Hate the authors that put their bile blogs behind the paywall. And all the people who applaud the bile over real content.

Now if he crapped on Electron development noobs in the free section and then demonstrated how to build Electron apps that take up 1/20th the resources and actually leverage native UI L&F behind the paywall, I’d support that.

2 Likes

No, I hate Medium too, their page is so encrusted with stuff that pops up on the top and right and has so much wasted space and so forth that I even have a greasemonkey script that just out-right deletes a lot of the DOM elements. ^.^

Yeah if someone could show how to get an electron app, like oh an IRC client, running inside of 20megs (mine runs in a lot less), I’d actually be interested in throwing a few cents to the author (not medium) for that. ^.^

3 Likes

You should post that script…behind the paywall. :slight_smile:

2 Likes

Lol. It’s pretty dead simple, I have a LOT of greasemonkey/tampermonkey scripts for a lot of sites that just outright delete things by either element ID or by a CSS selector and occasionally unbind some javascript event’s because a lot of javascript is really really bad and likes to lag and move stuff around. >.<

EDIT: For note, my usual pattern in a new grease/tampermonkey script is:

(function() {
    'use strict';
    function removeByClass(clsName, tries) {
        if(!(tries >= 0)) tries = 20;
        var elems = document.getElementsByClassName(clsName);
        if(elems.length === 0 && tries > 0) {
            setTimeout(function() { removeByClass(cls, tries - 1); }, 1000);
        } else {
            while(elems.length > 0){
                alert(elems[0]);
                elems[0].parentNode.removeChild(elems[0]);
            }
        }
    }

    window.addEventListener('load', function() {
        removeByClass('postMeterBar');
        ... etc more...
    });
})();
1 Like

Most desktop applications don’t need the DOM. They work just fine with non-nested text elements as opposed to multi level monster <div> trees.

I wonder if Quantum’s render could be specialized to mimic something like Qt instead of a Browser, an if so, could it be as performant as Qt?

And since we’re duscussing it, the what is your favorite way of developping desktop GUI apps? Qt? Platform-native tools?

1 Like

someone who can make an Electron app run in less than 20MB probably deserves way over a couple of cents xD ahahah

2 Likes

Eh, think of color coding, if you use such a thing you will get huge div/span trees regardless.

Honestly I’d just use Qt straight.

Qt is the GUI system I’ve used for the past, like, decade now. Well other than starting a 3D rendering context in OpenGL and rendering that way.

2 Likes

Not if you resolve the styling yourself and render a flat list of spans, right?

1 Like

A tree 1-deep is still a tree with a set of calculations equal to the number of nodes. ^.^

1 Like

I think a good alternative for most of these online-only Electron “apps” would be Progressive Web Apps on the desktop. A few thoughts:

  • (probably?) Better memory footprint than Electron - comparable to a second browser window open. We all have our browsers open all the time anyway
  • Similar development environment - the thousands of self-taught javascript developers would still be able to create desktop “apps” that can access your microphone, camera, location or give notifications.
  • Better security and more control for the user - thanks to the browser sandbox
  • (opinion) If an app needs filesystem access, it probably shouldn’t be written in javascript. If you need a cross-platform GUI, try QT or wxWidgets. I even think it’d be better if we had a webpack and node/npm stack alternative written in rust.
1 Like

VS Code is decent

NOTE: Rant coming up. Feel free to skip the rest.

There is always degrees in hell. Electron is a symptom of something much worse. It is said to see all the resources thrown away. But to some degree it has always been the case.

I don’t know how sloppy client side development can be justified really? The only reason is that there is a large amount of developers out there who doesn’t know that it can be done in another way. Who hasn’t actually seen how snappy and beautiful a well crafted client application can be in comparison. Well of course there are quite a large number of other explanations, but I don’t think the common ones are any good. For example:

  • Do you prefer not to have any software or have something written in electron?
  • Developers time is more important than wasting resources
    )

Modern web sites/apps are equally bad. Heaps of sites are border-line usable today. And there is no need for it. Surely the developer who makes these sites must go to them and feel crap about themselves? Or are they just a small cog in a big wheel and they don’t care about craftsmanship?

I mostly develop server side software. And I can’t just tell my customers (well I can but it doesn’t fly) you need to run this on 64GB of RAM 32-core system to be able to do the basic rudimentary things. We are handling multiple thousands of requests per second serving millions of customers on less hardware than required to run slack without getting the fans going

But somehow, it is a-ok to waste your customers resources away when developing client side applications.

For a while our team developed server side software against low-speced hardware. This helped us find stupid bottlenecks early which wasn’t covered up by an overkill of hardware.

I think every client side developer should do this as well. They should run their application on basic hardware along side any other normal application a user would have opened at the same time.

How something like electron can even pass basic QA is beyond me. The performance is amateurish on anything but modern hardware.

Thanks for listening :smiley:

3 Likes

I think the answer is simple cost and speed of development, to give an example from my work (unrelated to electron) we had 2 endpoint products 1 built in python by 3 people team 1 built in C++ 150 people team. The python one has 3x the features of C++ one.

1 Like

Honestly I don’t think you need naything else… If people were willing to pay for performance we’d have applications with great performance. Well, people aren’t and we don’t :stuck_out_tongue:

3 Likes

People don’t know that they can get better things so they don’t ask for it (+marketing, flair over functionality)

And I absolutely don’t think it is more costly to develop software with good enough performance. The developer is making the wrong choice. It would be no more costly to do things properly instead of being lazy.

Things doesn’t have to be super-optimized but is should never be an order of magnitude slower like it is today.

3 Likes