What is asm js

What is ASM.js and what does it mean for everyone?

I'm starting to hear rumors about this project called ASM.js. Right now their website is awful and confusing. I know the following from my research on the Internet.

  • It is a subset of JavaScript that can be highly optimized. I suspect because it avoids the more dynamic parts of the language.
  • The performance of code compiled in ASM.js is about half that of C (not light).
  • It is by design that compilers set their target language ASM.js.
  • Firefox is shipped with the ASM.js optimization.
  • The Mozilla and Unreal teams ported the Unreal Engine on the train with him and its course in a build of Firefox at near native speed.

There doesn't seem to be any specific information on the internet as to what this really is is or what use or purpose it ultimately has. Can I compile my otherwise server-side code bases and run them in the browser at almost native speed? What are the consequences for developers?


You already described what it is is . The usage is that it is a simple language written in all Browsing works, in most cases, quite quickly and in some cases very is fast. What you make of it is as open as what you do with any other programming language.

The use case that Mozilla seems to be most interested in is as follows: There are already ways to compile languages ​​with LLVM backends (most popularly C and C ++) via Emscripts to JavaScript. asm.js comes very close to what Emscripten already outputs, so that Emscripten code (which is already impressively fast on today's JavaScript JIT compilers) can become even faster, which promotes the goal of porting existing code bases to the web. Exactly what you use this for is your decision. Porting games is a use case (which Mozilla appears to be actively involved in), but there are tons of things written in C and C ++, some of which could be useful to someone's website. Some that I've seen thrown around (and some that I've made up) with no guarantee of feasibility:

  • Porting general purpose algorithms (e.g. zlib, libjpeg, openssl, FFT implementations) to allow JavaScript / websites to do more without creating a new web standard and depending on the individual browsers to implement it.
  • Porting of interpreters so that languages ​​other than JavaScript can be executed in the browser with less effort and minimal porting effort.
  • Using asm.js as the backend for more compilers, especially those that don't map JavaScript well and don't need most of the functionality and overhead. An example could be a language designed to work quickly numerically without allocating memory.
  • Using asm.js to create a JIT in JavaScript. It can implement any language - for example, ActionScript.
  • Likewise, the porting of existing JIT compilers for execution in the browser (see porting of interpreters with practically no overhead via JS). This is probably only possible if JIT compilers are generated automatically, as with PyPy.

Think of ASM.js as a large binary ArrayBuffer called a heap and a series of JavaScript modules that begins with a Prolog directive. Perform fast, low-level operations on raw binary data, similar to what you would do in assembly languages. These modules could be handwritten or, better, compiled from LLVM code using scripts such as Emscripts. Their performance has increased thanks to the Mozilla OdinMonkey engine, but they are backwards compatible with most modern ECMAScript interpreters.

ASM.js isn't limited to games, you can even run entire Qt apps in your browser like this one!

We use cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By continuing, you consent to our use of cookies and other tracking technologies and affirm you're at least 16 years old or have consent from a parent or guardian.

You can read details in our Cookie policy and Privacy policy.