V8 engine and Google Chrome browser will better support Asm.js

    About twelve hours ago, John Resig tweeted on Twitter that at the Google I / O conference, it announced an improvement in Asm.js support in the V8 engine and in the Google Chrome browser.

    Since Asm.js was mentioned on Habrahabr ( 1 , 2 ), its advantages could become known to many readers. All the more pleasant for them to anticipate now in the very near future the appearance of these advantages not only in the Firefox browser (where they were first introduced by the Mozilla Foundation), but also in the V8 engine (and, therefore, in the Node.js engine built on its basis !), And in the Google Chrome browser.

    But for those readers who have so far missed this novelty by themselves, I will also briefly recall the essence. Asm.js is a special subset of the JavaScript language: restricting itself to it in its script, the author of the script provides the ability to optimize the interpreted code not only at the time of execution (just-in-time, JIT), but even in advance (ahead-of-time, AOT ), that is, it becomes possible for such a javascript once to unambiguously pre-match some machine code. This effect is achieved at the cost of noticeable efforts to limit oneself. (In particular, using the operation “ | 0and other similar special techniques, the type of the value of each input parameter of the function, as well as the output value, turns out to be uniquely specified and unchanged.) But its result is an unprecedented increase in the speed of execution of the javascript - now it is inferior in speed to the compiled program (in C or C ++) no more than twice.

    The main direction of the practical application of Asm.js does not even lie in the field of manual programming (in which conscious observance of Asm.js restrictions may turn out to be unacceptably painful for a programmer), but in the field of fully automatic transcompilation (translation into JavaScript from other programming languages) a whole series is enough complex programs and libraries that become no less cross-platform than JavaScript itself. As a means such transkompilyatsii most known Emscripten , and partly also and Mandreel .

    We are on the verge of a future in which so many programs from among those working with the command line (not requiring a GUI) can be immediately made cross-platform(Node.js will ensure their execution on Windows, Mac OS X and Linux), for which it will be enough to compile them in JavaScript (using LLVM and then Emscripten) instead of machine code - and double the speed of their execution.

    However, the impressive examples on the Emscripten page clearly show that some such graphical applications that can work through EGLinstead of a specific graphical API (OpenGL, or OpenGL ES, or OpenVG). True, such Node.js applications will not be enough - you will need to transfer them to the Web, that is, the execution of applications in browsers. Firefox and the Google Chrome browser that joined it in Asm.js support will start to execute them with the aforementioned unprecedented speed. But it is easy to predict that all other browsers (IE, Opera, Safari and so on) will also be able to execute them non-selectively (because Asm.js is a subset of ordinary JavaScript); the only difference will be in execution speed.

    Also popular now: