docs: Update the "Electron vs NW.js" document (#22836)

* docs: Update the "Electron vs NW.js" document

* Update docs/development/electron-vs-nwjs.md

Co-Authored-By: Charles Kerr <ckerr@github.com>

* Update docs/development/electron-vs-nwjs.md

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

* Update docs/development/electron-vs-nwjs.md

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

Co-authored-by: Charles Kerr <ckerr@github.com>
Co-authored-by: Mark Lee <malept@users.noreply.github.com>
This commit is contained in:
Felix Rieseberg 2020-04-07 18:31:40 -07:00 committed by GitHub
parent 6bf83e9244
commit b4447be037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 75 additions and 52 deletions

View file

@ -1,52 +0,0 @@
# Technical Differences Between Electron and NW.js (formerly node-webkit)
__Note: Electron was previously named Atom Shell.__
Like NW.js, Electron provides a platform to write desktop applications
with JavaScript and HTML and has Node integration to grant access to the low
level system from web pages.
But there are also fundamental differences between the two projects that make
Electron a completely separate product from NW.js:
__1. Entry of Application__
In NW.js the main entry point of an application is a web page or a JS script. You specify a
html or js file in the `package.json` and it is opened in a browser window as
the application's main window (in case of an html entrypoint) or the script is executed.
In Electron, the entry point is a JavaScript script. Instead of
providing a URL directly, you manually create a browser window and load
an HTML file using the API. You also need to listen to window events
to decide when to quit the application.
Electron works more like the Node.js runtime. Electron's APIs are lower level
so you can use it for browser testing in place of [PhantomJS](http://phantomjs.org/).
__2. Build System__
In order to avoid the complexity of building all of Chromium, Electron uses [`libchromiumcontent`](https://github.com/electron/libchromiumcontent) to access
Chromium's Content API. `libchromiumcontent` is a single shared library that
includes the Chromium Content module and all of its dependencies. Users don't
need a powerful machine to build Electron.
__3. Node Integration__
In NW.js, the Node integration in web pages requires patching Chromium to
work, while in Electron we chose a different way to integrate the libuv loop
with each platform's message loop to avoid hacking Chromium. See the
[`node_bindings`][node-bindings] code for how that was done.
__4. Multi-context__
If you are an experienced NW.js user, you should be familiar with the
concept of Node context and web context. These concepts were invented because
of how NW.js was implemented.
By using the [multi-context](https://github.com/nodejs/node-v0.x-archive/commit/756b622)
feature of Node, Electron doesn't introduce a new JavaScript context in web
pages.
Note: NW.js has optionally supported multi-context since 0.13.
[node-bindings]: https://github.com/electron/electron/tree/master/atom/common

View file

@ -0,0 +1,75 @@
# Technical Differences Between Electron and NW.js
Like [NW.js][nwjs], Electron provides a platform to write desktop applications with web
technologies. Both platforms enable developers to utilize HTML, JavaScript, and
Node.js. On the surface, they seem very similar.
There are however fundamental differences between the two projects that make
Electron a completely separate product from NW.js.
## 1) Entry of Application
In NW.js, the main entry point of an application can be an HTML web page. In
that case, NW.js will open the given entry point in a browser window.
In Electron, the entry point is always a JavaScript script. Instead of providing a
URL directly, you manually create a browser window and load an HTML file using
the API. You also need to listen to window events to decide when to quit the
application.
Electron works more like the Node.js runtime. Electron's APIs are lower level so
you can use it for browser testing in place of
[PhantomJS](http://phantomjs.org/).
## 2) Node Integration
In NW.js, the Node integration in web pages requires patching Chromium to work,
while in Electron we chose a different way to integrate the `libuv` loop with
each platform's message loop to avoid hacking Chromium. See the
[`node_bindings`][node-bindings] code for how that was done.
## 3) JavaScript Contexts
If you are an experienced NW.js user, you should be familiar with the concept of
Node context and web context. These concepts were invented because of how NW.js
was implemented.
By using the
[multi-context](https://github.com/nodejs/node-v0.x-archive/commit/756b622)
feature of Node, Electron doesn't introduce a new JavaScript context in web
pages.
Note: NW.js has optionally supported multi-context since 0.13.
## 4) Legacy Support
NW.js still offers a "legacy release" that supports Windows XP. It doesn't
receive security updates.
Given that hardware manufacturers, Microsoft, Chromium, and Node.js haven't
released even critical security updates for that system, we have to warn you
that using Windows XP is wildly insecure and outright irresponsible.
However, we understand that requirements outside our wildest imagination may
exist, so if you're looking for something like Electron that runs on Windows XP,
the NW.js legacy release might be the right fit for you.
## 5) Features
There are numerous differences in the amount of supported features. Electron has
a bigger community, more production apps using it, and [a large amount of
userland modules available on npm][electron-modules].
As an example, Electron has built-in support for automatic updates and countless
tools that make the creation of installers easier. As an example in favor of
NW.js, NW.js supports more `Chrome.*` APIs for the development of Chrome Apps.
Naturally, we believe that Electron is the better platform for polished
production applications built with web technologies (like Visual Studio Code,
Slack, or Facebook Messenger); however, we want to be fair to our web technology
friends. If you have feature needs that Electron does not meet, you might want
to try NW.js.
[nwjs]: https://nwjs.io/
[electron-modules]: https://www.npmjs.com/search?q=electron
[node-bindings]: https://github.com/electron/electron/tree/master/lib/common