Posted on:
I know this sounds crazy, but I always wondered why do we always give out such a speedup technique as asm.js (it speeds up code in all the modern browsers!) to developers from other languages if we can use it for own code in JavaScript as well?
The answer is that handwriting asm.js is tricky due to limited set of operations and complex rules for satisfying asm.js. So I decided to start this side project. It's goal is to compile statically typed ES6 (Flow-flavoured) module into asm.js while preserving ES6 module interface. So it's still a subset of JavaScript, but much more suitable for hand-writing.
You don't need to use C/C++ -> Emscripten -> asm.js for heavy calculation anymore - just create module, drop Babel with this plugin and you're ready to go!
Currently supported: #
- ES6
import
and namedexport
- automatic
var
,let
,const
extraction and conversion - automatic function layout
- function parameter annotations
- function return type annotation
- assignment with automatic type conversion
- Flow type cast into asm.js type cast
- automatic asm.js imports for stdlib and foreign references
- automatic program layout
- automatic wrapping into asm.js module with
initialize
for passing ownheap
TODO: #
- bug fixing
- global variable support
- string support (literals are already converted to IDs, need to support operations)
- better asm.js<->normal code communication
- limited object and array support
- sky is the limit!
More posts:
- Next: Github project: babel-plugin-uglify
- Previous: Github project: proxyfill