[Из песочницы] Another way to write cross-platform apps: Neutralinojs internals and comparison with Electron and NW.js
I am Shalitha Suranga from Sri Lanka. I started Neutralinojs project with other two members as our research project at university.
These frameworks are being used to create numerous cross-platform applications. Whereas the community pointed out several unseen drawbacks of these frameworks. Large bundled application size, high memory consumption and long development workflow are the key things which were criticized through internet forums and websites , , , , . Table 1.1 shows the advantages and disadvantages of Electron/NW.js.
Table 1.1: Advantages and Disadvantages of Electron/NW, js
|Advantages of Electron and NW.js||Disadvantages of Electron and NW.js|
|Access native functions via node runtimeSingle codebase for all supported platforms Linux, Windows and macOS||High memory consumption and slowness|
|Many Node modules need to be installed|
Electronjs and NW.js like chromium-node based frameworks couldn«t reduce application bundle size further because embedded components size couldn«t be dropped further. A possible solution is introducing a new cross-platform application development framework which is having all the advantages of Electron and NW.js but which is lightweight, portable and lightweight for the computer memory. Importantly each platform has built-in browser component which can be used instead of embedded chromium. Windows platform has MSHTML (IE10/11) and Linux has gtk-webkit2.
Furthermore, there is a default web browser in each platform too. Therefore, chromium module can be replaced with either user«s web browser or web browser component. Node run-time can be replaced with a lightweight web server which exposes native OS functionality.
This research introduces a new framework architecture which delivers an implementation of portable, lightweight cross-platform application development framework including the proof of using top front-end frameworks. The new framework will use browser component or user«s browser instead of embedded chromium and will replace node run-time by introducing lightweight server run-time which exposes required OS level functions. Key features of new framework architecture design can be categorized as, lightweight, portable, simple development workflow and native access.
Application bundle and application development kit are the same, and it will occupy very less disk space. Application bundle can be compressed into a desired archive format in order to reduce its size further.
Application development kit should be fully portable, means that no prerequisites are required before the development process. Thus, application package also should be fully portable, Therefore no prerequisites are required before the execution of the application which was built with the new framework.
Simple development workflow
Application development workflow should be as simple as possible. No dependencies should be installed over the internet saving developer«s time and network usage. Thus, debugging application should be simple as Electron does .
Figure 1.1: Neutralino solution design
Figure 1.2: Neutralino server design
An incoming HTTP request gains access to native interfaces via CML which creates or reuse a separate thread for functional execution. Body parser parses the message and sends relevant data to request router which calls particular native interfaces. There are two background threads. UI thread runs the main native window loop, Ping receiver thread stops the Neutralino server when the browser tab was closed in debug mode. Configuration map is an in-memory structure which holds key-value pairs for application configuration.
Figure 1.3: Neutralino client design
A Neutralino API call invokes a function in Neutralino client library. Thereafter the related function sends an XHR via XHR library to the Neutralino server which responds incoming requests.
Neutralinojs brings a better portable and lightweight cross-platform application development framework comparing to other frameworks such as Electron and NW.js according to the research outcomes. Whereas research team has implemented only most required features basically focusing on a POC. Therefore, all the features are in those frameworks may not available on Neutralino at this moment.
Get started with Neutralinojs today!
Find Shalitha Suranga on Github for more open source projects