Show HN: Electrino, a featherweight API-compatible alternative to Electron
github.com
github.com
https://news.ycombinator.com/item?id=14245183
I posted a comment lamenting that Electron apps are so big because each contains a full set of the Node + Chromium runtimes, and proposed a lightweight version of the same concept using the system-provided web browser engine.
The idea seemed interesting, so I spent some time today putting together a minimal proof of concept.
This initial version of Electrino can load the "Hello World" example from Electron's quick start guide -- and that's pretty much it! With that enormous caveat, the difference in file size is huge. The Electron version sizes up to 115.7 MB, while the Electrino version is 167 kB.
I'm curious if this could be turned into a real project. Anyone out there with a small Electron-based Mac app that you'd like to put on an Electrino diet? Ping me, and let's see if we can make it work!
The full browser DOM is certainly there. The missing APIs are the Electron-specific ones that apps can use to access desktop features.
Adding new APIs individually is pretty easy, but there's a lot of stuff in Electron, so reaching full coverage is of course a lot of work... That's why I'd like to try adding APIs based on usage in real-world apps, "filling in the gaps" so to speak.
I wrote a blog post with some more details about the rationale behind Electrino: https://medium.com/@pauli/put-your-electron-app-on-a-diet-wi...
I know it would add extra time to the build on the programmer end, but what about component API's -- to keep build size at a minimum while allowing access? I haven't looked at any of the code -- would this be possible?
Any thoughts?
A lot of electron apps don't need the full capabilities of electron - what would be dope is if you could selectively add packages for these things.
The other huge downside of electron is performance - particularly with complex apps. If you could make any headway into that, I'd be 110% on your side.
The system runtime is loaded just once (and is probably already in active memory), whereas each Electron app loads its own copy of Chromium.
For large apps, it won't make a huge difference. I'm absolutely not saying Atom or Spotify should switch away from Electron... The use case I had in mind for Electrino is more about small utilities, desktop widgets, that kind of thing.
For complex apps, I imagine the picture can be very different. The use case I see for the Electrino approach is small apps that are constantly loaded. Big productivity-style apps are better served by Electron.
http://scribe-src.github.io/scribe-api/doc/
Support for OSX (with ObjC bindings exposed):
https://github.com/scribe-src/scribe-platform-osx
And could work with just MachO binaries (not .app dirs) by shoving data into a loader segment.
What you'd need is node (without webkit) which translates to ~9MB, + launching with the system browser.
9MB or so would still be a large step down from entire chromium runtime, but desktop apps still will have access to things like fs module, which are needed for desktop apps.
I made stubs for "path", "url", "process" so that the Electron Hello World can be loaded. Doing "fs" next seems like a good idea, but I'd like to have a real-world app to test it against to see which APIs actually get hit (rather than just reimplementing all of "fs").
I saw your comment yesterday and it really gave me something to think about. I swear if you don't go down this path I will as soon as I get a chance!
Ideally developers would have a spectrum of choice: all native libraries (Electrino), native browser + Node (your suggestion), Chromium + Node (Electron). They could then pick what works best for the scale of the project.
I can see how the architecture is greatly simplified, and I can still imagine using something like this... but giving up npm is a lot.
Re: npm, you can of course still use an npm-based workflow for the browser-side part of the app (Webpack, whatever). It's just the Node-side services that are missing.
For most apps I'm sure this is fine though.
Unfortunately neither v1 nor 2 have been actively developed in the past few years.