TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Doing work locally minimizes problems with Electron apps

285 pointsby jlongsteralmost 6 years ago

37 comments

jlongsteralmost 6 years ago
I&#x27;m the author of the post and I should also say that I don&#x27;t love Electron. It&#x27;s a practical choice for getting an app of the ground, but I want something more lightweight eventually.<p>I see it as a stop-gap until I can invest more resources into something more lean. But I&#x27;m focused on the product right now, not rewriting the world and wasting time because of engineering ideals.
评论 #20274989 未加载
评论 #20275347 未加载
评论 #20276823 未加载
评论 #20276127 未加载
评论 #20274831 未加载
评论 #20281719 未加载
评论 #20275345 未加载
评论 #20275774 未加载
评论 #20281699 未加载
评论 #20274859 未加载
mhdalmost 6 years ago
The problem I see with many electron applications isn&#x27;t just that they&#x27;re bloated (they probably are in about the same relation to average RAM that Tcl&#x2F;Tk apps were or early Gnome&#x2F;Mono ones). [Edit: To clarify, I mean the average RAM at the time they were accused of bloat]<p>It&#x27;s that they&#x27;re quite non-native. And not just in the &quot;button borders are 1 pixel wider than usual&quot; sense -- they&#x27;re usually styled to resemble web applications, with big data views, Material UI, etc.<p>Going from this to something more lightweight&#x2F;native doesn&#x27;t just require a different API, it requires a completely redesign.<p>In other words: The Big Rewrite That We&#x27;re Definitely Going To Do Someday(tm).
评论 #20275144 未加载
评论 #20275773 未加载
评论 #20275456 未加载
评论 #20275592 未加载
评论 #20279262 未加载
评论 #20281915 未加载
asdkhadsjalmost 6 years ago
So, I love the role that Electron fits, but boy do I hate how much we discuss Electron itself.<p>What we should be discussing is providing the functionality of Electron without the cost. A protocol that behaves like React native. Ideally a spec, which any language can implement and provide a native UX to the end user.<p>Some projects try (ProtonNative, for example), but I&#x27;ve not seen one go quite far enough. I don&#x27;t want to be forced to write a JS app to get benefits here. After all, with ReactNative, it&#x27;s basically a process RPC to a bunch of widgets. `process &lt;-&gt; UI`. So why be forced to write JS? An open spec would do wonders here.<p>I&#x27;ve not invested cycles on solving this problem, of course. Yet I can&#x27;t help but wonder why so many people are focused on solving UI issues with very narrow solutions like Electron, ReactNative, ProtonNative and so forth. They&#x27;re great projects, but a slightly wider vision would make them amazing projects.<p>Thoughts? Am I missing something obvious?
评论 #20275512 未加载
评论 #20275473 未加载
评论 #20275158 未加载
Sahhaesealmost 6 years ago
I&#x27;m not an electron hater, but when only using 300mb of memory while idle is something to boast about, they may have a point.
评论 #20274723 未加载
评论 #20274685 未加载
wlesieutrealmost 6 years ago
Electron discussions often focus around the battery and memory impact, one other thing I&#x27;d mention is the poor access to native features. You get the stuff a web browser can do, but for anything else offered by the OS you might need to wait a while.<p>For example, Apple shipped their first TouchID laptop in 2016, and Electron&#x27;s support for that landed in v6.0.0 beta 1 just last month.<p><a href="https:&#x2F;&#x2F;electronjs.org&#x2F;releases&#x2F;beta?page=2#6.0.0-beta.1" rel="nofollow">https:&#x2F;&#x2F;electronjs.org&#x2F;releases&#x2F;beta?page=2#6.0.0-beta.1</a><p>I&#x27;d looked at switching off 1password to BitWarden and that&#x27;s a pretty major feature to be missing for three years.<p>Surprisingly, for as much as everyone craps on the touchbar, that got supported by Electron a lot faster than TouchID did. I guess because not all apps need authentication and they can rely on passwords instead, while it&#x27;s really obvious when an app doesn&#x27;t have touchbar support.
评论 #20277672 未加载
评论 #20275343 未加载
gfodoralmost 6 years ago
If electron apps&#x27; claimed memory causes your computer to go slow due to swapping, you should complain. But most complaints I see on this topic stem from a discomfort over the reported figure by the operating system. With SSDs and modern virtual memory systems the claimed memory figure is not a sufficient measure to infer the resource utilization of a process. For example, if slack has a bunch of allocated memory that is rarely accessed, it&#x27;s going to (at worst) land on your SSD and sit there, having no impact on your user experience.<p>If you want to complain about applications&#x27; engineering, you should complain not about claimed memory but about things that are directly affecting resource utilization or user experience like power draw or excessive CPU utilization due to poor programming. Claimed memory must be combined with a profile to show that cold reads are common enough for the claimed memory figure to be correlated with a performance hit. But of course, this often isn&#x27;t readily available without profiling for all but the most extreme cases, and so engineering types fixate on easily visible measures like claimed memory that likely have no actual resource utilization impact in most cases.
评论 #20275498 未加载
评论 #20275879 未加载
cpursleyalmost 6 years ago
Thanks for the post.<p>&gt; I want something more lightweight eventually<p>Check out <a href="https:&#x2F;&#x2F;github.com&#x2F;revery-ui&#x2F;revery" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;revery-ui&#x2F;revery</a>
评论 #20275104 未加载
评论 #20275112 未加载
评论 #20275193 未加载
toygalmost 6 years ago
300mb of memory to do a bit of money-counting, which you could probably do equally well with MSVC in 2mb.<p>Such a wasteful world.
评论 #20274837 未加载
评论 #20274768 未加载
评论 #20274826 未加载
评论 #20275149 未加载
评论 #20275754 未加载
m48almost 6 years ago
Obviously bundling nearly all of Chromium with an app is inherently inefficient, but out of curiosity&#x27;s sake, has there been any objective analysis of <i>exactly</i> what makes this use a seemingly disproportionate amount of resources? Are JavaScript runtimes inherently inefficient? Is it Electron&#x27;s node.js part? Is it the huge amounts of code needed to parse and render HTML and CSS? Is it the multimedia features, like WebGL and the video and audio players? Is the problem actually just badly written code running on top of Electron? And if so, what <i>exactly</i> are are most Electron apps doing wrong that one could avoid? Is it, as this blog post seems to suspect, that they aren&#x27;t sufficiently taking advantage of Electron&#x27;s node.js integration?<p>In addition, once the actual bottleneck has been identified, doesn&#x27;t this open the door to fix things on the WebKit&#x2F;Blink engine side of things? Before, when Electron was managed by GitHub, one could say this would be unreasonably difficult, but now that GitHub is owned by Microsoft, isn&#x27;t tweaking Blink to be more suitable for deployment environments outside of Chrome exactly the type of thing they would have a vested interest in doing, and the resources to actually pull off? After all, with VS Code, they are one of the highest-profile Electron users, and using Blink in Edge presumably involves working with the Blink code to some degree anyway.<p>It&#x27;s always struck me that a lot of Electron apps likely never use a single line of WebGL, while a lot of WebGL apps likely only use DOM APIs to pretend the DOM doesn&#x27;t exist by plastering everything in a huge &lt;canvas&gt; element, and both likely don&#x27;t want their binaries to include the Chrome devtools, but Electron includes all of these things anyway. I&#x27;m not sure how much space or resources it would actually save, but is Chromium&#x2F;Blink refactoring their code and build process to facilitate Electron building different Electron &quot;profiles&quot; that include different sets of features even remotely a possibility?
rmrfchikalmost 6 years ago
Not only memory is the problem with electron, but also app feeling. Skype left is the only electron app I&#x27;m using. And comparing to desktop messaging app (telegram): 1. Skype unresponsive. Opening chat takes up to few seconds. 2. I see how opened chat is literally updating -- messages, avatars, emoticons emerges from dust 3. Selecting messages as messages in native vs selecting messages as text with surrounding artefacts (chat is a html page with all what comes with it)<p>Summarizing, electron apps are just feels like foreigners.
olliejalmost 6 years ago
I have never had an issue with electron apps being terrible because of networking - although clearly there are apps that do push more work than is necessary over the network, there’s plenty of native software that does too.<p>My problem with electron apps is that they use way more memory and cpu than they should be - the architecture fix for that would be to not be a full browser.<p>The problem I have is they lack basic app behaviors from the platform. My experience is mostly for the Mac, but my experience using vscode on Linux has been similar.<p>But here we go, for a Mac:<p>* cmd-e&#x2F;f&#x2F;g are so wide, not just app wide. Vscode goes even further and seems to achieve per-view behavior.<p>* document editors and viewers are expected to have an icon for the file being edited, either in the window or in the tab. That is a draggable link to the file, and a drop down on right click for the directory hierarchy.<p>* drag and drop of files into and out of the windows don’t work<p>These are basic behaviors that even the simplest apps manage to get right on OS X, yet no electron apps seem capable of meeting this low bar.
adgasfalmost 6 years ago
People love to bash Electron, but what is the alternative?<p>Is there any other platform that provides:<p>- Support for the 3 major desktop platforms from one code-base;<p>- A decent choice of high-level programming languages (there are excellent compile-to-JS options now);<p>- Reasonable tooling and community support;<p>- MIT (or similar) license
评论 #20276939 未加载
评论 #20276502 未加载
评论 #20278147 未加载
评论 #20282518 未加载
grechtalmost 6 years ago
I use VS Code and it never felt sluggish. But it’s probably one of the best Electron apps out there.<p>Honestly, if I had to develop a Desktop app today and wanted it to be cross-platform, I’d probably use Electron. No need for hacky workarounds like in a web app to make it run on every major browser.
评论 #20275265 未加载
jlaroccoalmost 6 years ago
I honestly don&#x27;t know why people waste time building Electron apps.<p>It&#x27;s the worst possible combination. All of the downsides of web apps (poor performance, memory use, poor integration, etc.) and native apps (security problems, hard to update, etc.), without the advantages of either one.<p>Why would I want to download your specially packaged browser, without adblock or uMatrix or any of that, just to basically view a website anyway?
评论 #20277743 未加载
评论 #20277758 未加载
chasd00almost 6 years ago
I&#x27;ve never noticed Electron apps negatively impacting my computer. I use Slack all the time and I don&#x27;t notice a difference when I have it running vs when i don&#x27;t. Do most people not like Electron because the number seems high or does it negatively impact their computer in some way? (I have a MBP with 8 gig RAM, that doesn&#x27;t seem out of the ordinary)
评论 #20274789 未加载
评论 #20274808 未加载
评论 #20274805 未加载
edoceoalmost 6 years ago
I am an electron hater but this is a really good setup. Server reloading with that debugger is rad. I&#x27;m going to use these methods with a platform I don&#x27;t like.
geodelalmost 6 years ago
Well to me it is thing that should not be done at all, instead of doing it diligently.<p>I will put this in category of &#x27;The secret of good user tracking on web&#x27;, &#x27;the secret of doing quality journalism on ads supported model&#x27; or &#x27;the secret of nuanced political debate on Twitter&#x27; etc.
vijaybrittoalmost 6 years ago
Unrelated: I really hope software like <a href="https:&#x2F;&#x2F;github.com&#x2F;revery-ui&#x2F;revery" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;revery-ui&#x2F;revery</a> becomes mainstream!<p>This node IPC debugging technique is pretty nice!
评论 #20277598 未加载
langitbirualmost 6 years ago
The hate for Electron is strong in this thread.<p>For Electron haters, here are the alternatives: OpenJFX (some people hate Java), Qt5 (it can be pricey in some situations), wxWidgets (not popular enough?).<p>However, I have a lot of hope for Flutter in desktop. I hope the developers of Flutter framework can pull off the challenge.<p>In my case, for opensource projects, I definitely use Qt5 (using PySide2). But for proprietary projects, I have to admit that most likely I will choose Electron.
评论 #20282980 未加载
michannnealmost 6 years ago
I&#x27;m building an application using Electron and I&#x27;ve found the majority of memory consumption occurs when instantiating new components. When using a UI framework like Material, this can happen frequently, such that the simple act of hovering over a menu and showing an indicator can cause an increase of 3 MB of RAM. I love Electron, it allows me to create applications in an intuitive way using a language meant for building UIs, rather than slapping a library on a native codebase, and I can deploy it wherever Chromium is supported, so I&#x27;d like to make it efficient, wherever possible.<p>Two solutions I have found during my development:<p>1) Keep your components light. Most of what I used from Material can be done completely with raw HTML and CSS in a simpler fashion without much going on in terms of state, so I created my own components that serve my purposes. A lot of libraries and frameworks are heavy because they are used on webpages viewed by multiple different browsers and require complex logic to work across different environments. Electron sandboxes your code in Chromium + node, you code only for 1 browser engine, so I hope more devs take advantage of that fact.<p>2) Load what you know you need in the beginning, and keep your cache to a minimum. Most Electron apps do not have view transitions, they are built as SPAs. One of the downsides of this is that you need to be mindful of your cache since it is not cleared when you display a new component. Clearing the things that don&#x27;t matter to the view or data has been essential in keeping my memory footprint small.<p>With a large app that does many things and loads many views, I&#x27;m able to keep the RAM usage to under 200, most times around 150, which, while larger than something like Excel running idle, is a small price to pay to have intuitive design features and access to a large and constantly growing library of reusable components and packages.
imtringuedalmost 6 years ago
The type of developer that chooses Electron isn&#x27;t going to care about squeezing out the best performance possible. They already made a conscious trade-off to sacrifice performance and memory usage in exchange for productivity. They won&#x27;t do some hacky things like use Rust instead of nodejs.
fabiospampinatoalmost 6 years ago
It sounds like a generally good approach for keeping the UI process responsive at all times. I wonder if the serialization cost behind all those IPC calls becomes an issue at some point, especially when passing large structures back and forth, have you found this to be an issue for your use case?
评论 #20278427 未加载
评论 #20275277 未加载
skrebbelalmost 6 years ago
I feel like the key idea here is somewhat unrelated to writing Electron apps. It&#x27;s that you can set up any Node server app to run inside an Electron window during development and then you get cmd+r and all the devtools for free. Kind of like a node inspector on steroids. Pretty nifty!
ptxalmost 6 years ago
If you need a background process to call Node APIs because &quot;it&#x27;s the only place where it&#x27;s safe to access them&quot;, what unsafe way is this meant to contrast with? Does Electron normally (but unsafely?) call Node APIs from the browser process?
评论 #20278661 未加载
评论 #20278416 未加载
chrisweeklyalmost 6 years ago
Thanks for sharing! Your post is full of things that might seem obvious in hindsight, but all too likely to be ignored absent a compelling writeup like yours. Bookmarked the linked repo, will revisit w&#x2F; my next Electron app.
fmakunboundalmost 6 years ago
What are the 83 threads used for in that trivial budgeting application?
smith-kylealmost 6 years ago
I made something similar a couple years ago: <a href="https:&#x2F;&#x2F;github.com&#x2F;smith-kyle&#x2F;electron-process" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;smith-kyle&#x2F;electron-process</a><p>But I love the addition of defaulting to a node server for lower memory usage.<p>The Atom editor (the first Electron app) has slowly been rewriting a lot of their modules in C++ for speed and lower memory usage, binding to them through NodeJs. Kind of ironic since GitHub created Electron to build desktop apps using web technologies.
UtahDavealmost 6 years ago
Vote for Linux support in Actual here:<p><a href="https:&#x2F;&#x2F;trello.com&#x2F;c&#x2F;A7XzJgJX" rel="nofollow">https:&#x2F;&#x2F;trello.com&#x2F;c&#x2F;A7XzJgJX</a>
评论 #20278370 未加载
ulisesrmzrochealmost 6 years ago
The argument about bloat is so weak tho. Engineering about trade-offs. If you can’t tell why people use Electron, you’re not a good engineer.
falcolasalmost 6 years ago
IMHO, good electron apps feel and behave like native apps. Or, in the worst case scenario, they feel like an equivalent web app.<p>Specifically - I should not have to think of having to “ctrl-R” for a desktop application.<p>Good electron apps do exist, but they feel like a vast minority. Most just feel like a bloated version of their web application.
评论 #20274875 未加载
评论 #20274997 未加载
评论 #20274735 未加载
sys_64738almost 6 years ago
My simple rule of thumb for reducing the memory usage of Electron apps is to not run any of them. Problem solved. It&#x27;s like why I never ever installed java which was subpar garbage. Gosling has a lot to answer for.
z3t4almost 6 years ago
I would just skip Electron and make a PWA (add2desktop) instead.
emptyparadisealmost 6 years ago
I miss native apps.
bfrogalmost 6 years ago
The secret is don&#x27;t use electron.
ionisedalmost 6 years ago
I find the problem lies with the trade-off you are making.<p>You are making your life as a developer easier in exchange massively increasing the resource requirements and battery usage on end-user machines.<p>It&#x27;s just bad practice and Electron encourages it.<p>I feel like if we ever want to be taken seriously as a profession the way structural or mechanical engineers are for example, then efficiency and reliability need to be primary considerations, otherwise we are basically making toys.
评论 #20274984 未加载
IloveHN84almost 6 years ago
First rule: if you need Electron, change your requirements&#x2F;design and move to something more cross platform like Qt or libui&#x2F;C++.
评论 #20277204 未加载
评论 #20275388 未加载
makkesk8almost 6 years ago
Some people seem to think that unused ram is good, quite the contrary actually. If you have 50 of these apps running doing work while playing a game while having a pc from 10 years ago, then I can actually see a problem. Laptop and battery-driven devices is a whole other matter though.<p>I like to think the reusability and speed of development with electron is just terrific and is a trade-off that is worth it in the end.
评论 #20275242 未加载
评论 #20274921 未加载