2 ms·
> I'd also be happy if the browser vendors came up with a new bytecode from scratch as well, designed for the web. I would actually really like this, if define
by pcwalton 13y ago
> I'd also be happy if the browser vendors came up with a new bytecode from scratch as well, designed for the web.
I would actually really like this, if defined as an isomorphism to asm.js. (asm.js core operations are pretty simple, it's only the JavaScript syntax that is funny.) Anyone can do it. Write a compiler in JS that compiles this WebBytecode to asm.js (and PNaCl if you want, though I'm not sure if you can dynamically generate PNaCl at runtime from JS) and evals it. You could then ship apps with this bytecode today and have them work in all browsers, and it would be, effectively, completely standards-based since the asm.js semantics would be normative and the asm.js semantics are defined by the ES6 draft spec. You'd be able to ship a clean bytecode representation, unsaddled with the legacy baggage of JavaScript or LLVM, and cross-browser compatibility with what could be, if implemented properly, a tiny stub loader.
The biggest hurdle to getting it working in PNaCl would be wrapping the Web APIs in the Pepper APIs as an "inverse pepper.js", but that should be done anyway as any app that wants to target the standards-based Web APIs and the Google-specific, nonstandard Pepper APIs will want this.
- cromwellian 13y agoI don't think the problem with asm.js is the on-the-wire format, it's the semantics. Someone writing native C code wants threads and low level currency primitives. Javascript is fundamentally unable to model that, and Javascript as designed for the browser does not model synchronous blocking either (XHR sync and dispatchEvent notwithstanding) I feel like both PNaCL and asm.js are a kludge in search of a problem. I just don't see either of these winning over say, DICE to implement Battlefield 4 in a browser, or Valve for the next Half-Life franchise. Triple-A developers don't want to leave performance on the table, and running your code inside of a browser virtual machine, even a C-based sandboxed one virtually guarantees that. Asm.js might be vitally important for a platform like Firefox OS, but I doubt either PNaCl or Asm.js will ever be something the drive by web bothers with, because the kinds of applications that need native levels of performance are also the ones native developers are most likely to do native platform specific ports for. That is, having to recompile and port from Win32 to OSX to Linux is worthy tradeoff vs losing 20-50% performance off the bat, not to mention the different purchasing behaviors of Web users vs console or native mobile users.