loading...

Desktop Apps With JavaScript: Electron And Friends

kayis profile image K ・3 min read

Imagine this: You meeting up with the most senior front-end developers ever and they tell you that Web UIs are totally pleb tier and you can't seriously get any more senior than writing desktop apps. So you search around and find all this crazy stuff like GTK+, Qt and Swing and you realize you don't even know a bit of Java or C++.

So how can you, a JavaScript developer, hold your ground?

Rest assured, for there are projects out there to save your dev cred!

NW.js

The first one is NW.js. In the beginning it was called node-webkit, but I guess since they use Chromium and Chromium itself uses Blink instead of WebKit, the name didn't made much sense anymore.

Anyway, its idea is to merge Node.js and Chromium into a runtime environment for Web-applications, that can access system APIs. So you can use all your Web skills to create desktop UIs and then use your Node.js skills to do all the regular system stuff, like sockets or filesystem access.

The whole runtime is rather heavy, tho. Also memory usage isn't quite like that of a Qt app ;)

Oh and it can run Chrome apps directly, if this is your thing.

Electron

Electron came a few years after NW.js and did things a bit differently. It also uses Node.js, but it only uses parts of Chromium, which should lead to faster build times.

Also, while NW.js is more browser centric, Electron is first about Node.js. So instead of starting with a Web-page, you start with a Node.js process and create your Web-page windows from there.

It's as heavyweight as NW.js, but seemingly used by much more projects these days.

Nidium

Nidium is one of the new kids on the block. It doesn't use Chromium or Nodejs, but Mozillas JavaScript engine SpiderMonkey, with some extras like networking, datastorage and video, written in C++.

It's much smaller than Electron and NW.js, but it doesn't include a whole browser.

You get APIs like Canvas 2D context and WebGL. It comes with its own small layout engine that even has a DOM compat layer, so you can use frameworks like React to structure your apps.

I guess not all Electron and NW.js apps can be rewritten in Nidium, but probably a good part of them.

It also runs on mobile devices.

Electrino

Electrino is a reeeally fresh thing out there. The project just started as a proof of concept, but its based on an interesting idea, to use the preinstalled browser of the OS instead of Chromium and re-implement the Node.js APIs most Electron apps use.

Because Chromium is a big part of NW.js and Electron this could lead to smaller binaries.

Conclusion

Well, probably depends on what you need, like with everything. :D

I guess Nidium could be nice for games and such.

The question of "Electron or Electrino?" (if it becomes ever usable) probably boils down to the question "How much do you want to depent on the OS?". It's nice to ship tiny binaries, but it's also nice to control all the libraries.

Discussion

pic
Editor guide
Collapse
defman profile image
Sergey Kislyakov πŸ‡·πŸ‡ΊπŸ‡ΊπŸ‡Έ

Didn't know about Nidium. Looks very promising.
Though I'm tired of apps that includes a browser in them. I wish Electron could share the chrome instance between the apps so they won't be that big and RAM-unfriendly.

Collapse
ben profile image
Ben Halpern

I hadn't heard of it either.

Collapse
felipernb profile image
Felipe Ribeiro

Just adding CEF - en.wikipedia.org/wiki/Chromium_Emb... which is used by Spotify and Steam, for example...

Collapse
kayis profile image
K Author

But it's not stand-alone, right?

Where do Spotify and Steam embedd it into? A simple C++ app or Qt or something?

Collapse
felipernb profile image
Felipe Ribeiro

Yeah, you're right, it's not stand-alone.

You need a wrapper for it, usually a simple C++ or you can use one of the bindings for several other languages.

I just thought it was worth mentioning because it's probably the first (big) project to do this, even before NW.

Thread Thread
felipernb profile image
Felipe Ribeiro

A bit about the Spotify Desktop app: youtube.com/watch?v=9UsnX5X_DF0 ;)

kayis profile image
K Author

Hehe, true.

Reminds me of a developer I met, back when I was in university, who told me they simply wrote a Web based front-end for their customers and when they whined about browsers not supporting it or that they can't install new browsers, they simply made them a Qt app with a Webkit view. Somehow "stripped down browsers" were okay for enterprise admins, haha.

This was 2010, so it seems to be "a thing" for a long time :D