loading...

Electron can be better [RANT]

kailyons profile image KaiLikesLinux ・2 min read

Let's make up a situation to explain why Electron is enticing. I am a new developer, very limited in ways of skills. I am proficient in HTML/CSS, with enough JavaScript knowledge to make something work with enough documentation. I have made my app idea, but I want it to use HTML/CSS, as I know how that works. I want easy implementation with JavaScript, I heard about NodeJS, and I want to test it out. I ask my friends would it be better to use UI tools like GTK and Qt available for all languages, or should I use an implementation made by the programming language devs like VUI for V language. We talk and talk until one asks, "Since you know HTML/CSS so well, and you love JavaScript, why not use Electron?" Electron is something I never heard about, my friend explains, it uses NodeJS to emulate a browser, and I can use HTML/CSS to build GUI applications. Electron is a game-changer for me.

Why should I not use Electron? There are many reasons the Electron library is terrible. Notice the wording I use, I say: it emulates a browser. What I mean is, it creates a run time environment with Chromium as the backend. A reasonably modified version of Chromium is what Electron uses. To say this is a bad idea is an understatement. Not only is this a slower method of running a browser, emulating. There are many ways to do emulation, but that isn't required to explain. Emulation is a slow process with running everything on the front-end. While emulation isn't the most delayed, it can be as sluggish to run as containerized systems like Snap.

The main three issues behind Electron being terrible are that it uses emulation or emulation-like systems. It doesn't have a custom HTML/CSS engine. It borrows from Chromium, a browser not too keen on speed. Removing any one of these issues will make others either mute or disappear. Replacing Chromium will help speed enough where we can ignore the emulation, and the custom HTML/CSS engine can be put off. Using a custom HTML/CSS engine removes the issues with speed in emulation and the Chromium problem. Removing their emulation, and using the code from Chromium itself, will make the speeds of Chromium not important enough for the short term to get a new engine or make a custom-built engine.

Electron has issues, but as a whole, the project is usable and well documented enough to say it is still a decent project for web applications. These are my complaints and from my technological standing of how Electron works.

Discussion

pic
Editor guide
Collapse
huncyrus profile image
huncyrus

Hi,

Interesting "rant". Rather an interesting opinion and point of view.
I would like to add my personal opinions also.
I often work on different projects what uses Electron. I would say, its speed is depend, what and how you would like to achieve something. I agreed on that, littlebit weird and maybe overkill (or overhead) to have an enbundled browser engine what run headless for you and do the backend and frontend in the same time, but there is one huge advantage against any other solution: cross compilation. I compiled myproject under 5 minute into 3 different platform. And I was not forced to pollute with bloatware (java, .net...) the operating system, and did not required to set up the environment for it. Just run and use. Same experience, UI, workflow and abilities. (I know, I can do the same with C++ for example, but personally, I do build way slower any kind of UI on that language...)

Collapse
ianfabs profile image
Ian Fabs

I think you might like webview, a rust crate that leverages the default rendering engine of the host Operating System. It's pretty slick!

Collapse
kailyons profile image
KaiLikesLinux Author

I personally dislike Rust, but it actually seems really cool. Thank you for sharing!