Ask HN: Do you think Electron is good for building Desktop Apps?
At Oursky, we built several apps with electron.
We find that it's easy to set up, you can use npm packages. Yet the build size is quite big and it might not support all native features. What's your thoughts?
165 comments
[ 2.6 ms ] story [ 205 ms ] threadI prefer to write apps with separate server and client parts and the client JS/HTML is generated by in-house tools and thus is a fraction of the size of anything that would uses any of the popular frameworks.
In any case, I'm finding that WebApps are easier to deploy and update than writing for native deployment. In the rare cases that I do need native features, I can deploy a local server which can then access whatever I need. The clean separation of concerns between client and server does simplify architectural design.
It's a trade-off for me, I use it when the trade-off feels right.
The disadvantage that is most talked about is its final bundle size, and I'm not aware of any developments that are trying to solve it. I'm in a project with a number of Electron apps built and in the pipeline, and we're searching for a potential in-house solution, of a central app that hosts/downloads/embeds "mini-apps" that run on the same foundation, to share the same Chromium run-time. Really hoping for a community solution to this though.
https://github.com/electron/electron/issues/673
It got a bit daunting to see in more detail the potential complexity of the problem. Someone noted in the comments here, that there have been countless attempts at solving this "shared runtime for cross-platform apps" idea, apparently with a still unsatisfactory history.
Reading through the thread does give me hope, since the discussion is on-going after 2+ years, which means people are interested in an efficient solution. Seeing the HN crowd go at this Electron topic again and again, always with a kind of emotional "turbulence", implies that this is a worthy problem to solve.
I like that one of the recent suggestions is to "split the Electron", to accommodate bindings with theoretically any language.
If you need to have a desktop app quickly (for multiple platforms, even) and it's the difference between launching something or not, then yes it is good.
If memory footprint and performance is a critical part of what you're doing (it's not always), then maybe you should look at a different technology.
I think Electron has allowed a lot of cool things to come into existence that wouldn't have if not for Electron.
for modern [web] developers.
Contrary to what one might think by reading tech blogs and HN, developers come in more varieties than just "web" and "wizard".
1. Ease of building and distributing packages with Electron-Builder. I'm able to build for all three operating systems on my Mac, took a few hours to set up.
2. Access to the vast NPM library for all sorts of functionality.
3. Ability to use CSS libraries for styling. I'm no designer so it saves me some time. Collate uses Bulma for styling.
From what I've seen, users are more than happy to have an application that solves their need no matter what it's created in. Most people don't really think about file sizes, or the fact that Chromium is packaged with Node, they just want their problem solved without visual or performance hiccups.
If it wasn't for Electron, Collate would be a very different application or non-existant. I think people need to look at Electron as opening the door to more possibilities.
- You can find libraries for "all sorts of functionality" with ease for native languages - Swift, C#, Python (Mac, Win, Linux).
- In the end the ability to use CSS is harming user because now you don't have default OS element styling and every app is using it's own styling for things like buttons - this is very bad.
Exactly. If you're building an app yourself you'd never have the resources to make a native app for Mac, Windows and Linux. Nothing is perfect in software development. Electron is a decent tradeoff for certain projects. Regular customers aren't going to even consider disk space or memory usage unlike many vocal commenters in this community.
To be frank, most users often don't have a better performant alternative (outside of maybe a browser tab) so it seems like a redundant point.
Seriously, WebKit on Mac and Edge on Windows would be just fine for >99% of Electron apps. Using the available web runtime would be a tremendous saving both in build size and memory usage.
Did you know that Chromium contains 25.3 million lines of code? [1] Each Electron app is bundling a separate copy of that enormous codebase in binary form. It's a terrible waste of memory.
It's true that supporting the native web runtimes would be more work for the Electron framework developers, and sometimes would also mean more work for app developers... But most web apps have absolutely no good reason to be tied to Chromium, so for app developers the diversity would actually be beneficial in the long term IMO.
If someone wants to start a project that's like Electron but uses the native runtimes, I'd actually like to contribute some work. Let's call it "Electrino"?
[1] https://twitter.com/worrydream/status/857794605076500480
Now that I only use Slack to communicate with former coworkers I just keep it on my phone.
Are you short on disk space? Download is too slow? Is this a real problem?
In 1995 my computer had 8 or 16 MB memory... Having a 1 MB app running in the background would have been huge. I certainly don't want to go back to that era.
To make matters worse, memory growth has stagnated. A Macbook Pro today, to give an example has the same maximum RAM (16Gb) it did in 2010. That's zero memory growth in 7 years for a popular developer machine.
Each Chrome tab is a process, but they share the same dynamic libraries in memory. Each Electron app is both a process and a separate copy of the dynamic libraries.
If you run half a dozen Electron apps, those redundant libraries will be taking up roughly a gigabyte already.
But when every utility and menubar widget has its own copy of Electron, the footprint balloons quickly. And people are actually doing those kinds of apps in Electron already!
I was expecting this to happen after chrome discontinued their "chrome apps", that the underlying tech would come back with progressive web apps, but I haven't seen anything in that space.
I think it would solve the problems with Electron apps (wouldn't have to rebundle the runtime for a massive binary size and massive memory use).
If anyone knows if anything is happening in this space (progressive web app installation for desktop) please let me know.
If it's just a web app (network, localStorage etc) then it would be fine. But if you need to read/write to the user's filesystem or need to include other executables then we can't run that in our browser. We don't want a webbrowser to have any possible path to screwing with your filesystem or running executables.
EDIT: Found this: https://mobile.twitter.com/nolanlawson/status/71266809721643...
Static binding vs dynamic binding?
Bundling everything up so no outside deps are needed vs using everything that is on the system to save space?
The Electron approach is fine for genuinely large applications. But I've seen many Electron-based Mac desktop apps where the UI has a handful of elements. The equivalent Cocoa app would be maybe 100 kB.
I understand that people won't learn Cocoa just for tiny UIs, so it would be really nice if there were a mostly Electron-compatible solution that would use the system web runtime which is already there (and probably already loaded in active memory).
They built a framework for, as you say, "genuinely large applications" but it seems to be so easy to use that it's used especially for small ones.
https://github.com/pojala/electrino
Sorry, it's totally empty! But I'm hoping to get around to making a Cocoa+WebKit proof-of-concept this week. I guess the starting point would be to implement just enough APIs to be able to run the main.js example from this Electron tutorial:
https://github.com/electron/electron/blob/master/docs/tutori...
Then narrow the few missing desktop-focused APIs that Electron has but Cordova doesn't have good plugins for. (It would also be nice to support more Node-like background processes in Cordova and more Node-native libraries, but you would need to find a good balance that plays well with mobile.)
https://openfin.co/2016/11/04/openfin-slashes-electron-memor...
Here's the Show HN:
https://news.ycombinator.com/item?id=14260755
- Sensitive data that you do not want to be known by thid parties
- Very interactive applications where consistent subsecond response times are needed
- Applications that rely on data located in the computer (for example from other desktop applications)
Also, bundling lots of different Chromes in apps which may or may not ever be updated feels like a security issue.
With that said, IMO Electron is great purely for the reason that it opens desktop development up massively.
I've written native apps before and it has been a world of pain. Electron lets me use tools and skills I already know to spin up desktop apps. I know I'm not the only one who this applies to, and there are a bunch of apps that probably wouldn't exist if Electron didn't. It's usually a false equivalence to compare Electron apps to full native apps.
If the choice is between an inefficient Electron app, or no app at all, I'll take the Electron app any day.
For now all the google-about things would always end up to benefit google instead bring convenient to user. Yes I just hate google, And what they bring to the web(For recent years only)
I think something like Electron should have been made but all I could find now is web browser or game engine.
There are already too many silly Apps on mobile platform, and Electron is just another that silly things in my eyes, since I'm just a stupid and arrogant user
No, it is a terror. Applications produced with it are bloated monstrosities, gobbling up hundreds of megabytes in both storage and RAM before getting round to as much as putting a checkbox on screen. Bundling an entire web browser inside your program in order to provide portable GUI functionality like what Tk managed more than twenty years ago without breaking a sweat, and at roughly 1/100 the size, yeah, sure, it flies. So did the Spruce Goose, sort of.
But then, I never took to js, I never took to Chrome, I never took to bloat as a way of life.
[edit: typo]
It is totally embarrassing that programs are 100-1000 times the size they used to be, and slow. I think it shows an overall disinterest in our tooling and field, and it's shameful.
When unpacked, it weighs about 100MB. This disk space costs roughly £0.004 for an HDD or about £0.020 for an SSD.
In exchange for these extra costs, I get to use HTML, CSS and JS on both our website and our desktop applications and they get to share the same codebase. That alone must saves me 50% of the time. The fact people might have to spend upto 3 more minutes to download my application and that it costs them 2p to install it on their SSD is minimal compared to the fact that I can have twice as many features in the same amount of time.
Why use JS when you can have Lua for scripting and a less annoying programming language for main code? Why use HTML and CSS when you can have a dynamic portable native UI as in Qt?
I smell laziness and cutting costs in those decisions, or rather offloading the costs onto users.
Have you tried NPM? If I want to write every single line of code for my application, I don't expect it to ship (unless it's extremely simple). When there is a library for almost everything, why not use one instead of trying to reinvent the wheel?
[0] http://www.modulecounts.com/
We also had libraries long before every language needed it's own package manager.
I have written Java, C and C++ when I was younger but I enjoy scripting languages more and they have provided for me well enough.
But, let's be honest here, "worst" is your bias for the languages which doesn't actually say anything other than your opinion.
Last time I checked, each window in your Electron app had to run in a different process. This is a design that makes sense for a web browser like Chrome, but not for the majority of desktop apps.
If your app is simple enough to only need one window, this won't be an issue, but otherwise, I found it a major pain.
Only useful for web-only teams who have no desktop experience whatsoever. If you can afford to hire a desktop team, do it.
The relevant bugs are upstreamed to Electron.
[1] https://kivy.org/#home
- Bindings to Tk (Tcl; cross-platform GUI toolkit).
- Bundled with Python.
- Easiest to use but has the least features.
- Ugly on Linux and is difficult to theme.
- Good choice for small applications if you only care about utility.
PyQt (or PySide):
- Bindings to Qt (C++; cross-platform GUI framework).
- PyQt is GPL licensed and supports Qt 4 and 5.
- PySide is LGPL licensed and supports Qt 4 (support for 5 is in development).
- The pixel perfect purists dislike it on Windows and Mac.
- Good choice for large applications where an almost native look is sufficient.
PyGTK:
- Bindings to GTK+ 2 which is obsolete.
PyGObject:
- Bindings to GTK+ 3 (C/GObject; cross-platform GUI toolkit).
- Comparable to Qt.
- I've heard Windows support isn't the greatest (this may be obsolete now).
- I'm biased and perfer Qt over GTK on Linux.
- Good choice for large applications where an almost native look is sufficient.
wxPython:
- Bindings to wxWidgets (C++; cross-platform GUI toolkit).
- Comparable to Qt.
- Uses native widgets on Windows and Max, uses GTK+ on Linux.
- Good choice for large applications where a native look is required.
Kivy:
- GPU accelerated GUI framework.
- Does not look native.
- Good choice for graphically intense applications that do not need a native look.
My recommendation is:
- Small, utility program: Tkinter.
- Large application: Qt (if an almost native look is sufficient).
- Large application: wxPython (if a native look is required).
- Graphically intense application: Kivy.
And as an Old, I do believe there's a serious cultural problem, caused by the Web Rush, where the industry as a whole does not care enough about zero/low-cost abstractions.
Something else to consider are your development skills. If you never worked with something else than web technologies, electron is hard to beat in terms of dev experience.
Electron has made me forget those days! Today, most of the tools I use are available on all platforms and while they do take up a lot more ram and disk space - both are generally things I can buy and fit on my computer and will be supported out of the box but not having those apps won't.
I know it's great to hate Electron because of how much ram and disk space it takes, but for those few on Linux, it's truly made life easy!
As you may surmise, I do not entirely agree with you: I have tried the odd Electron application, but I don't think any of them lasted a week on my desktop. It's not just the bloat in itself. Software built on what I consider iffy technologies - somehow I never really manage to trust them or just feel reasonably comfortable with them.