Can regular JavaScript be converted to asm.js, or is it only to speed up statically-typed low-level languages? -


i have read question how test , develop asm.js?, , accepted answer gives link http://kripken.github.com/mloc_emscripten_talk/#/.

the conclusion of slide show "statically-typed languages , c/c++ can compiled javascript", can "expect speed of compiled c/c++ 2x slower native code, or better, later year".

but non-statically-typed languages, such regular javascript itself? can compiled asm.js?

can javascript compiled asm.js?

not really, because of dynamic nature. it's same problem when trying compile to c or to native code - need ship vm take care of non-static aspects. @ least, such vm possible:

js.js javascript interpreter in javascript. instead of trying create interpreter scratch, spidermonkey compiled llvm , emscripten translates output javascript.

but if asmjs code runs faster regular js, makes sense compile js asmjs, no?

no. asm.js quite restricted subset of js can translated bytecode. yet first need break down advanced features of js subset getting advantage - quite complicated task imo. javascript engines designed , optimized translate advanced features directly bytecode - why bother intermediate step asm.js? js.js claims around 200 times slower "native" js.

and non-statically-typed languages in general?

the slideshow talks …just c/c++? onwards. specifically:

dynamic languages

entire c/c++ runtimes can compiled , original language interpreted proper semantics, not lightweight

source-to-source compilers such languages javascript ignore semantic differences (for example, numeric types)

actually, these languages depend on special vms efficient

source-to-source compilers them lose out on optimizations done in vms


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -