233 points · by gozzoo · 7y ago · 299 comments
Does the Electron team have a focus on improving performance? Or is the issue with the developers using electron, should they be optimizing better?
I assume it's some of both, but curious if anyone with more experience in electron can provide any insight as to how the performance changes over time.
- The operating system cannot share memory between different Electron processes. Normally if you start many processes of the same binary, the memory is shared and only copied on write. Since each Electron app is a different binary (even though they are 99% identical) they each eat memory.
- The above applies to disk size as well. Electron apps are usually huge, and 99% of the binary is the same as all your other electron apps.
This is mostly why I'm against electron. If electron worked like the JVM and each app shared a runtime, many issues would be solved, including many electron apps running old, and vulnerable versions of Chromium. Now it's only updated if the developers decide to ship a new version.
Discord is an intelligent start up that was able to pivot from a chat client to a games marketplace with a one-click update. Their use of the erlang VM shows that they make considered tech decisions based on tested technology. I think their use of electron, at least from this users perspective, was a great decision. I realize they are just one example of electron apps, and I'd have a harder time defending a file-unzipper or some madness using Electron, but it no doubt has its uses. To suggest otherwise would be premature optimization at best.
I use Discord and like it, but it is incredibly slow at starting, switching rooms, and even just loading new messages.
But the most aggravating thing is that I can't type a message on mobile if I don't have internet connection. It requires connection to load the input field. Affects me every day in elevators. Most native apps just lets you write your message and sends it when connection is back.
Fine, Discord is useful, but I must respectfully disagree that their app is good. And it is definitely possible to make natively.
It seems to me that most apps are written in Electron for two reasons: it lets you write apps in JavaScript that are conceptually very similar to web apps, so you're not learning a new weird-to-you language like C# or Swift, and it lets you go cross-platform with far less effort--you're writing one app rather than three. But this doesn't mean that you're not making tradeoffs in both performance and usability when you choose to go this route.
There may come a point in time when a well-written native app won't trounce an Electron-based app in terms of memory footprint, startup time, and integration with the host platform. But that time is not now, and it's silly to pretend otherwise.
https://medium.com/commitlog/electron-is-cancer-b066108e6c32
Who are all these masochists using Tkinter? There are a ton other APIs to consider, and even more if one wouldn't mind updating an old one to be current (think XUL). I think this is the second or third thread where that particular toolset has been named as if it were the only alternative to Electron
I hate Electron too but is everyone really so new to the game that they do not remember desktop programming?
There's Swing, GTK, QT, JavaFX (maybe), WinForms....
The issue with memory consumption is definitely there.
But the issue for us is that if you're doing ANYTHING with 'content' you just have to use the web platform.
You need CSS, HTML and with pdf.js we have somewhat first class PDF support (though a few features are missing).
If it's a calculator app, then sure. Don't use Electron. It would be too bloated.
One feature in Polar that simply wouldn't be possible is support for web content caching.
We support downloading web pages for offline usage to allow annotation and to prevent bit rot.
It wouldn't be possible without some sort of web control but having full chromium (plus a webserver) means that you can setup a near perfect clone of the web but on the desktop.
I have a theory that the loudest complainers about this are the leftovers of the computer ricer era, who liked to display a bunch of metrics on their screen that mostly amounted to fluff. Electron solves real problems.
Signed, someone who's built and shipped native apps on the various platforms, and groans anytime he has to do a basic chart or whatever because it'd be 10000x easier in a web browser.
Edit: furthermore, the browser handles caching things like images and what not, which bloats up the memory in Electron. There is a way to force the browser to flush that stuff out, but nobody does it. If you have a local image cache for a native app and you don't flush it, you will get the exact same situation.
This application's purpose is to show text and little pictures (and occasionally process a few low-bit rate audio streams).
It is amazing that modern application developers are turning well solved problems for 90s computers into tasks modern computers can barely process.
Noted, and that's a fine use case for the Browser engine + HTML + CSS + JS/WASM tech stack - but how many native apps need that sort of rich view?
Lately I have been building apps with tkinter/python/asyncio and I can't get over how fast the apps are to load and to use. There is none of this "let's not respond to the mouse for 5 seconds" that is staggeringly common on my mac (particularly for apps like Safari and iTunes that come from Apple) nor the "go for a walk around the block" loading times for Java-based apps on my i7 Windows laptop.
True tk apps are ass-ugly but I find it mind-blowing to use GUI apps that are as responsive as Windows 95 apps were back in the day.
I love Kivy as well as QT. You can make some decent looking apps with the former and some incredible ones with the later. I have never personally worked with Electron.
But yeah, most devs use JS, HTML, and CSS for ui creation because of the Web.
I think something like QML could replace the html and css parts, though.
Um because a lot of them already know HTML/CSS/JS (because they've worked on websites). This the the major reason why Electron is popular - the barrier to entry is very low. That combined with the fact that users don't complain, just makes it a "pragmatic" choice.
- I'm a JS/TS developer, with it I can make CLI apps, websites, Electron apps and mobile apps. This means I can also use the same set of UI widgets I'm familiar with across all platforms, I can't do that with any other native UI toolkit so far, maybe the situation will change with the advent of WebAssembly, but so far JS has basically been the only language capable of providing this.
- I don't think I've ever used a Java GUI app that didn't look like crap and wasn't a game, I've also never made a GUI app in Java, so this is just a guess, but maybe it's just easier to make prettier apps with web technologies.
Also if it's not built in JS, it's not cool these days
I prefer functionality over appearance, but I'm just a crusty old RDBMS DBA so I'm not sure my opinion can count for much.
So yes +1 cross platform GUI toolkit
If we could just get a modern UI lib w/ a C FFI you'd see a node wrapper and the complaints would reduce (yes I am aware of lots of efforts and could enumerate them all, but many are lacking).
I’m incredibly partial to Qt and love the framework (particularly the ability to style it and its C++/Python bindings). But even after making a small GUI application I can see why some would prefer more simple to use frameworks, whatever the resource or performance costs may be.
It looks like Python is your only option if you want a community of any sort who is actually doing GUI development with a scripting language (Perl/Python/Ruby)
Because it very much feels like so, especially with tkinter. And it's not only the toolkit, it's the OS integration, and installer and so on. Because making a cross platform app with Electron is relative low effort and you get very good results. Most of the other options are not even close.
I think an updated, nicer ttk would help considerably, as well as a bigger widget library, but there is little information on improvements to Tk as a whole (I can’t even find enough examples for asyncio...)
Anyone have good references for either?
tkinter specifically does not look very pretty without some effort. I would much rather use GTK or QT. The problem is GTK support on windows is limited, and QT has a weird license model.
For me?
Because every API I access returns JSON, and because half those API have a JS package sitting somewhere in NPM.
Bonus, a large % also have typescript definition files laying around.
So my choice is either:
1. Deal with JSON in native, and create my own wrappers for every API out there, because next to no one publishes C/C++ libraries anymore.
2. Give in to the JS behemoth.
tl;dr ecosystem.
On the other hand, requiring a shared runtime has been one the key reasons that a lot of cross platform apps failed in the past. How many times have others decried the fact that they had to install Java or Adobe AIR or XYZ in order to run an app they needed.
Unfortunately (or fortunately, depending upon your point of view), the JVM world has moved to a model of embedding a JVM with each app, as it can be less problematic for developers (and lets Oracle remove a bunch of subsystems from the JDK, reducing their development and maintenance).
On the up side, though, newer releases of Java provide jlink, so that the JRE can be stripped down to exclude subsystems that aren't used by the app. Also, several JVMs still support class data sharing, so if multiple instances of an app are launched, they can share some common class data.
This is in no way an endorsement for Electron, just an aspect common to all platforms that rely on an intermediate runtime that could in principle be shared.
While hard drive space is cheap on spinning drives, space on consumer devices has stagnated or even decreased with the move to ssd
But the memory one definitely is, I don't want each app to take 1GB of ram.
Here's one that doesn't suck:
Maybe that was very complicated to make, all I know is that it's blazing fast and doesn't hog memory. Or hey, take OggDrop and LameDrop, I'm sure there's programs that do the same, are 100 times as big and have 3 options. I don't know if there are 10x programmers, but I know there are 100000x programs, with not one electron app among them.
That should not be a significant issue in 2018 - all popular operating systems have same page merging support now and at least latest Win10/macOS also have transparent compression of memory pages.
The only way I think a common runtime could work is if Electron used the Runtime of the Browser. If every browser exposed an API to run JavaScript and Render HTMl using the browser's Engine that'd be great.
I think splitting out services from the browser makes it easier to focus on notifications and use window management to change contexts. It is confusing and frustrating that Apple has not allowed saving websites to apps yet.
Compared to Safari, Chrome’s performance is like a fat pig hogging your memory and devouring your battery life.
Though I feel like even if that happened people would still complain about it, mostly motivated by web technologies encroaching on the desktop space, threatening other developers “turf”, so to speak.
Sharing libraries is definitely more efficient but at the cost of isolation and versioning issues. Similar to some of the reason vms and containers are used.
Over time I have come to appreciate self contained apps and deal with redundant bytes at a lower level.
You mean like eerr, chrome - and the web :P
Every interaction ends up lagging like molasses, whether it is text input, window resizing, startup time etc.
We have video games that run 3D environments with gigabytes of geometry and textures at 144hz yet people are making simple text editors and interfaces with a dozen simple components (like the ethereum wallet) that run xwindows streamed over a 56.6 modem.
(My angle on this — I do high-performance 2d/3d animation work in the browser and in electron, with extensive testing of latency, energy usage, frame rate stability, etc)
I think most of the times if an Electron app is not snappy enough then the developers didn't spend enough time optimizing it, take a look at VS Code vs Atom for instance, I haven't used Atom in a while so maybe the situation in different now, but both are Electron apps, VS Code is fast and Atom is (was?) not.
VSCode also uses lazy loading so doesn't initate everything at once you click the launcher icon but does it progressively.
But a couple of years ago even simply writing inside Atom without using any extension felt sluggish to me.
TypeScript gets downcompiled to JavaScript anyway, so I don't think that's directly a contributing factor, but maybe because of the type system they can spend less time debugging and more time optimizing.
Because, you know, Microsoft.
I think the main issue is the developers, some apps don't use so much memory where others seem to use too much for the features they provide, IMO most JS developers do not understand how GC works and how you can by mistake keep objects alive.
There is also the issue where you do not have a default UI toolkit and some frameworks like angular are bad for performance(I mean how in angular codes I seen data binding trigger tons of unnecessary updates but maybe some will blame the developers using it wrong)
The inevitable thing that always gets brought up is memory usage.
It's really not insanely bad if the app is important. I wouldn't use it for a calculator but if it's an important app allocating 150MB of RAM seems worth it.
The biggest change here seems to be the build system and the upgrade to Chrome.
The Chrome updates are what's important here. Since Chrome is evergreen if your behind a few versions the standard libraries in NPM just stop working.
I got bit a while back when when they were a bit behind in releases.
This laptop has 16GB, why are people hemming and hawing over 150MB???
Okay? Having a lot of memory does not mean a program should be wasteful, nor does it mean everyone has that.
And in any case, less RAM usage usually means less cache thrashing which in turn means acceptable performance.
This isn't 2008, we don't need to care about 150MB like we used to.
It can be also used to quickly test an idea before dedicating platform specific resources.
I hope the team adds more features keeps Electron alive.
My big complaint isn't the resource usage, it's how the applications never feel right on any platform.
Web apps are universally worse in their UX than native.
I'd much rather learn 1 stack well, write the app once, and spend time _optimizing_ it rather then _reimplementing_ it.
- I can use the same UI components that I use for making websites and easily share code between all platforms. Maybe this will change in the future with the advent of WebAssembly, but right now no other stack gives you this.
- Bundling a cross-platform auto-updating app is wonderful. I just have to configure electron-webpack [1] and everything is taken care of. In the past I've made a password manager with GTK3 + Python, bundling it was a real nightmare and I don't think the situation improved much in the last few years.
- Sometimes, like when you're going to need a HTML renderer anyway, using basically a browser for rendering the UI can actually be an advantage, a couple of examples:
Example 1. Evernote needs to render their notes, basically arbitrary HTML, and the macOS app uses Safari's engine for this. Now they have to check across all platforms if their notes are always rendered the same, even for rendering a simple note they show you a spinner, and the native UI is arguably ugly anyway. In comparison my soon-to-be-released Electron note-taking app [2] looks more native to me, it's faster, requires less resources, and I get cross-platform support basically for free.
Example 2. I was using Ship [3], an app for managing GitHub issues. The native parts of the UI were written in Objective-C, the issue/comments part were written using web technologies, and their server was written in C#. What you get is an app that doesn't work across platforms and sharing code between all the parts of your application is basically impossible.
- Lastly I'm by no means an expert on other cross-platform UI toolkits, but some of them try to mimic the native widgets and do an awful job at that, as a result I don't have any Java GUI app installed because they all looked like crap to me, how many do you have installed on your desktop?
[1] https://github.com/electron-userland/electron-webpack
I propose that using web components for desktop/mobile applications is not a good thing.
Agree, every platform has it's distinctive look & feel and as a user I expect that my apps follow this for 100%. Recently I checked out Flutter, with the 1.0 release i thought it's worth to play around with it. The first thing i did, was installing their demo app on my iPhone they showed on the release event. Within seconds I noticed that there was something wrong. They tried hard to reimplement the bounce effect during scrolling on iOS, but it just didn't feel 100% right.
I totally understand, that not every user out there has this sharp eye for things like that and that there is definitely a business value going cross platform, but this is not something I would be proud as a developer. It's the cheap root for the developer ending up in a cheap experience for their users. Share your business logic between platforms if appropriate, theme it for your CI if needed, but do the UI as expected.
(Arguably that's a problem with Flutter too because it isn't "native" nor "web", it doesn't entirely meet the expectations of web users currently either.)
For better and worse, the web is a ubiquitous platform, and I think getting to be just about the only platform that matters today, regardless of the remaining fan wars between the "native" platforms.
It may not be, but it can be the difference between a developer releasing something that has real value to end users versus not releasing anything at all.
One could say that building an Electron app is an example of doing things that don't scale.
I know of no other framework that gives me this power.
We use websites with different UIs every day, can you imagine if we were also complaining that Facebook doesn't feel "native"?
However, most importantly for my day job, it's not good for security. Adopting Electron requires me to accept the same structural weaknesses that led to all of the NPM malicious commit issues that have cropped up lately, and with Electron it runs as me, the user, not inside a browser sandbox. As a dev in a security team, not inadvertently creating attack vectors is literally part of my job, so that combination of factors is scary. In hindsight... I'm putting Discord in a sandbox.
Other native languages/SDKs/frameworks don't have this issue if only because so much of them come from first party entities and it's very viable to cut implicit trust to the repositories.
That makes Electron not a viable option for anything related to my day job unless it's guaranteed to be running in a VM, closed off from everything else. When some of the Node.js permissions related stuff gets put in, I'm going to like Electron much, much more than I do now.
You could actually not use any external modules in your main process and have the renderer process sandboxed [1], node integration [2] can be disabled too.
[1] https://electronjs.org/docs/api/sandbox-option
[2] https://electronjs.org/docs/faq#i-can-not-use-jqueryrequirej...
Unfortunately, that only covers the rendering code, and it still backtracks a lot of the reason putting JS into a native environment is convenient in the first place. But it's a lot better than the "nothing at all" I thought it was before.
There are definitely awful Electron apps, but that's usually because of the developers, not because of Electron.
If you are so unlucky to be stuck on an ancient laptop with not enough ram, spinning disk, and an OS that doesnt't do the right things with virtual memory (non stop swapping for no good reason), that's going to be noticeable and annoying. Been there, done that, and it sucks.
If that is the case and you are a professional developer, get some decent gear, set it up properly, and stop whining. If on the other hand you are an end user, adjust your expectations accordingly to the fact that you are running old crappy hardware and don't try to install everything and the kitchen sink; or alternatively just be patient. Most users need nothing else than a browser running these days.
That's the kind of tricks that the DOM (so web and also Electron) were supposed to make irrelevant.
Write an app "naturally" with Electron, and it will likely be slow because of the DOM <-> data impedance mismatch. That's what slack is guilty of, but the ability to do so is Electron's claim to fame.
Same for their Javascript engine. Node could be running on Mozilla code instead of V8 if Mozilla had been more developer friendly.
There's more to Electron than that, but this might make it more feasible.
EDIT: seriously, it could run its own local server for privileged OS integrations, giving you an IPC API over REST.
You see endless 'concerns' about Electron resource usage. What you don't find are complaints that it's unstable, or that it only works on some desktops, or that it's hard to understand or use. It's solid, it works on all desktops and it's about as easy to use as such a thing can be for contemporary full stack developers.
For better or worse I think the whinging about resource usage isn't going to hinder Electron much.
Chrome now supports native notifications on Windows/macOS and even apps without full PWA support seem to work fine by just creating a shortcut and setting it to open as a new window without the browser's UI.
For some time you could do that with any web page in Chrome, with "the create a shortcut" option. But now Chrome opens them in a new tab, not in a dedicated window.
With so many Electron apps in the wild these days, it seems like a great opportunity for the standards bodies to comb them for good ideas for greater platform-wide adoption. (What are people doing in Node processes in Electron that would be tough to do in {Service, Web} Workers? What APIs for deeper native integration would be of benefit?)
Resource usage aside, there's far too much control of a given app being given to the Chrome team.
Who cares if it's secure but sucks so much that I'm not using it anymore?
Is the performance really that bad? Plenty of successful applications are using it. Is there a fix in the horizon?
VS Code is electron, I use VS Code every day without noticing any issues. I think the complaints about electron are moot.
But this is such poor logic. We can notice these things, while regular users just suffer not knowing why their battery drains so quickly, unable to pinpoint the problem.
No, it’s not. It’s at most a trade-off. Some developers will doubtless make this their hill to die on, but I suspect it really has nothing to do with performance or battery life, and it’s likely motivated by resistance to web technologies being used on desktop vs what they’re used to.
Also I’d like to see some actual battery life benchmarks for electron, because I don’t imagine that it’s a huge deal, but benchmarks would prove the matter. It also ignores actual desktop users or users who just use mains power all the time.
Now imagine if they were all electron based and therefore consuming 1GB+ each?
Also we need to take into account that it feels slugish and they are not as responsive as other apps, and i guess it has to do with JS VM reaching the tipping point of what it can do and optmize..
Anyway, my main point is that the big problem will happen when you stack those things.. than a computer that should be more than enough, just isn't.
Even the user with low tech awareness, will close the app and feel his computer is working better.. and they will blame the company who makes the app for making their computers feel slugish in the end.
If you think Electron works for what you need I would say use it and just ship, once you have more resources reevaluate if it is or is not working.
I'm quite sure that you got that backwards. Your dev machine may run Electron apps fine with 16GB RAM, but a huge majority of average folks are on 4GB and often less. And they're already running Windows 10 (or at best OS X) and a web browser with a bunch of open tabs!
VSCode and Discord to me are notable exceptions, whereas most other Electron apps feel pretty sluggish. They must be doing something right that other devs using Electron are not.
That said, I do still prefer the performance of native apps. Even though VSCode is fast for an Electron app, when I switch back to Sublime Text, I still realize the performance gap is there (especially for launch times, when I'm opening a bunch of small files at once)
Chromium itself is a memory hog and apps like Slack routinely take up to a gigabyte of memory. For a fucking chat app.
How many Electron apps does the average developer run on his machine now? I'm back-end developer and I still need four or five Electron apps running to do my job.
All in all they are taking up between 4-7Gb of memory. That's just absurd to me, and we are all on 2017 MacBook Pros with 16Gb RAM. Combined with Docker, IntelliJ, Robo3T etc, I'm pushing up against my RAM limit frequently, because Electron apps are all a bloated mess. Every single one of them.
It's even worse if we start getting multiple end-user apps are written with Electron, because the average consumer machine doesn't have a lot of memory like developer machines tend to have.
This kind of development shouldn't be encouraged in my opinion.
The big thing about Electron which most developer discussions miss is that it enables low-cost multi-platform development, especially if you already have a web app. In this age when people would like to pay as close to 0 as possible for software, this is important. I have a SaaS app and people keep asking me about apps for iOS, Android and native Mac/Windows. There is no way I could afford to develop+maintain for even one of those platforms. Of course most people who ask about this would like to get the additional platforms for free :-)
Electron makes it possible for me to re-package my app as a native one, with certain benefits (easier file uploads, access to printers and peripherals, etc), and with a reasonable cost.
Everyone here knows that Electron is the cheapest way to wrap a web app. It's obviously the fastest way for someone with web but not desktop experience to create a minimum viable desktop app. It isn't the only option for low-cost multi-platform development.
You have good reasons for producing a hybrid app instead of a native app. It's questionable whether Slack does.
Sure, the bundle size is large and the memory footprint is ~200Mb but those should not be limiting factors if you have a computer from this decade.
Of course, it means you have to deal with cross-browser issues, but I guess webdevelopers are used to this anyway. I'm also aware that these projects don't provide all the APIs that Electron provides, but many apps that are really just a wrapper around a webapp this is totally fine IMO.
I can also imagine there's some potential for sharing the same engine across multiple apps, though I'm not sure if they actually do this.
Like many websites in tabs in a browser, sometimes... it's easier to just kill the tab or window, and re-open it. Usually a sign you've done something wrong in your UI handling code.
https://www.reddit.com/r/javascript/comments/6f8u2s/githubs_...
I guess the good news is that this level of dysfunction should take care of the other Electron issues all by itself if we just wait a little while.
the official site just has a logo: http://electronconf.com/
- Huge distribution size. Your code is 1% at most. 99% is redundant. I want 10 meg at worst hello world dist size. - This is more a problem in JS ecosystem in general: No good enough standardized or not way to do the frontend part of the app. Angular is not good enough, neither is React or anything else. Though it is gradually getting better.
Isn't this already outdated by months?
Has anyone played around with flutter.io? Is it similar to electron?
https://medium.com/flutter-community/flutter-on-desktop-a-re...
You can laugh, but that day is coming and I fear getting armies of college grad hipster-coders creating unreliable slow layered software until we have nothing but "Material" UI flat buttons and cursor lag when typing simple messages in a simple application. AHHHH