A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Is asm.js compatible with ES6?

RReverser
2015-06-17

As far as I understand from spec, set of allowed node types is pretty limited in asm.js.

However, some ES6 features would be useful inside of asm.js code as well, for example:

  • destructuring as a way to import things:

    var { exp, log } = stdlib.Math.exp;
    
  • constants for even better code optimization (direct replacement with numeric value):

    const ANSWER = 42;
    
  • defaults as an alternative way to specify parameter types (following same semantics as for vars in section 5.4) + arrow functions purely for syntax:

    const geometricMean = (start = 0, end = 0) => +exp(+logSum(start, end) / +((end - start)|0));
     }
    
  • concise property syntax for exports:

    return { geometricMean };
    
  • (and probably others)

stuartpb
2015-07-07

I think asm.js is really mostly going to stay where it is for the purposes of providing a polyfill for browsers that don’t speak WebAssembly.