⬆️ ⬇️

Node.js + Chromium = AppJS: one of the promising options for the second step of the web developer development

Now we will talk a little about how the recent emergence of a new tool and related opportunities opens up the opportunity for modern web developers to quickly evolve, move to new levels, acquire new professional skills, and learn new areas of creative work. Such a tool is Node.js and the infrastructure growing around it.



The first step of the web developer’s evolution takes place when the developer meets Node.js and immediately realizes that he now only needs to use the knowledge of javascript and learn the fairly simple Node API to immediately get the opportunity to write not only scripts for sites, but also console applications , and even server (in particular, web server).



Historically, this is not the first of these tools.
Each of us can remember that there were attempts to create an engine for convenient programming in Java ( Windows Script Host , Rhino , JSDB , and so on) before Node.js appeared.

')

However, only Node has a fairly fast engine (V8), cross-platform, a simple API, and a great many additional modules . The combination of these advantages makes Node successful and convenient.


The second step of the web developer’s evolution is accomplished when knowledge of the JavaScript language (as well as other web technologies, primarily CSS and HTML or XML) can be used to develop more applications with a graphical user interface — that is, with a GUI.



Many manufacturers created tools for web-like GUI development.
Here you can recall a dozen more or less successful attempts to achieve the desired.



Mozilla Foundation invented XUL and XULRunner first , and then the whole operating system - Firefox OS .



Hewlett Packard has released webOS (more recently, Open webOS ).



Google came up with Google Chrome OS .



You can also recall that Qt has a JavaScript-based markup language GUI - called QML .



PhoneGap , Appcelerator Titanium , Adobe AIR, and other web-like programming tools for cross-platform applications are being developed.



Part of the above solutions was born weighty (for example, when a large virtual machine or even a new operating system is required to run a web-like application). Most of them will also require the programmer to learn some API, sometimes rather clumsy and scary (for example, XPCOM for XULRunner), but even when such an API is sufficiently elegant, it still takes effort to learn it. The more he can, the more extensive will be the API.



Meanwhile, if at the first step of its evolution, the web developer managed to learn the API from Node.js - is it possible to rely on this knowledge and not learn anything extra in the future?


The second step of the web developer’s evolution becomes a natural continuation of the first, if the markup and design of a web-like application is set using HTML and CSS, and the behavior is set using JavaScript, and the Node.js engine well-known developer works “under the hood” .



In particular, if you use AppJS , then the object model (DOM) of the demonstrated “page” contains the global Node.js object under the name window.node , and we can easily read the Node version in window.node.process.versions.node window.node.process.arch is the processor architecture, in window.node.process.platform is the platform, and display some such message in the window of our graphical application:



[screenshot]



(It is clear that you can use other Node.js features in the same way — network, file, and so on.)



What is AppJS?



AppJS is the Node engine, to which, as one of its modules, was added the WebKit engine from the Google Chrome browser, or rather from its free version, Chromium. Currently, Chromium is used in the form of CEF (Chromium Embedded Framework), which Dima_Sharihin told us in sufficient detail when he spoke about connecting Chromium to .NET. As you can see, the CEF can be fastened not only to the dotnet, but also to the javascript, which the creators of AppJS did.



Currently, the AppJS project is at the very beginning of its development and has not even reached version 0.1 yet - the demo assemblies on Github have the number 0.0.19. There is no documentation other than code examples; You can, however, familiarize yourself with AppJS capabilities even now, if you download the demo build (containing a kind of “hello world”) from GitHab to your operating system, run, read the source code and comment to it, make changes and see what it turns out.



In this assembly, under the name “ data / app.js ” is a file containing the settings of the main application window. When the window is created, the “ data / content / index.html ” page is loaded into it, which can access window.node and thus reach the Node engine.



The AppJS application window has many qualities of the Chromium browser, although it lacks the toolbar, the status bar, and other elements of the browser interface. In particular, you can press Alt + F12 and get a debugging console.



AppJS launches the Node engine with the “--harmony” key , so the application has all the features of ECMAScript Harmony that are available in V8.



Seeing such a promising project, I did not, of course, wait for its development to version 0.1 - before that, perhaps, there are still many weeks and months left - but I hurried to quickly familiarize Habrahabr readers with it.



P.S. AppJS is not the only project aimed at creating web - like GUI applications using the JavaScript language and the Node engine. Perhaps in the future I will tell on Habrahabr and about other similar projects.



Postpostcriptum And he told about node-webkit - a project that looks even more promising than AppJS.

Source: https://habr.com/ru/post/153013/



All Articles