4 ms·
I'm not sure "intrinsically superior" is the right way to think about this. If you were asked for a mechanism to get web clients to execute stuff "fast" that w
by ajross 13y ago
I'm not sure "intrinsically superior" is the right way to think about this. If you were asked for a mechanism to get web clients to execute stuff "fast" that was generated from a traditional C-like compiler front end, you surely wouldn't have designed asm.js. You'd probably have ended up with something more like the JVM or PNaCL.
It's true that asm.js wins for compatibility, for obvious reasons. And that's a powerful advantage. And it works in the same runtime that existing web apps do, which likewise a win; Java and especially NaCl have complicated interoperability paradigms. They are not just "a faster web page", which is what 90% of developers really wanted to begin with.
That said, the remaining 10% really do want something more. They want to write targetted architecture-specific assembly, perhaps. They want access to syscall-level abstractions like threads and true sockets (buffer sizes, Nagle settings, timeouts, etc...). And asm.js has nothing for these people.
And despite its simlicity, asm.js is still mostly just a toy. It's got one working compiler backend that isn't packaged sanely anywhere. I've three times now decided to get serious and build emscripten from source, and three times given up -- it lags LLVM releases, it has glitchy behavior. Compare to clang and especially gcc which build robustly and cleanly everywhere and come with elaborate test suites. This isn't a toolchain I'm about to start betting a company on, for sure.
Give it time. I like asm.js too. But it's never going to be The Answer to remotely deployable "native like" code any more than Java was.
- pcwalton 13y ago> They want to write targetted architecture-specific assembly, perhaps. Neither PNaCl nor the JVM gives you this.
- ajross 13y agoTrue enough, though NaCl does. I was mostly listing a bunch of stuff asm.js doesn't do to address the "intrinsically superior" comment, not giving a pros and cons list of specific technologies. Feel free to ignore that point if you like, I don't see that it meaningfully affects my argument.
- espadrine 13y ago> [emscripten] lags LLVM releases, it has glitchy behavior. Compare to clang and especially gcc which build robustly and cleanly everywhere and come with elaborate test suites. This isn't a toolchain I'm about to start betting a company on, for sure. Are you comparing emscripten to clang? Using clang alone won't get you something you can execute in a web browser — unless you include a CPU emulator in JS. If in fact you are comparing the asm.js workflow with the PNaCl workflow, they each rely on clang, sure, but PNaCl requires a bigger difference with clang-trunk. It is a plain fork. > PNaCl is essentially a modified version of Clang. This is done for two reasons. First, it eliminates an install-time dependency. Second, Clang was historically not supported on Windows (but this is beginning to change). Also, PNaCl has a unique, specific API (Pepper), which is very different from the way emscripten works. Finally, the comparative workflow to have your app work on the Web. PNaCl: write HTML/CSS/JS, write manifest, write PNaCl code, compile to pexe, rewrite the code to work with Emscripten, compile to JS via pepper.js. Emscripten: write HTML/CSS/JS, write native code to work with Emscripten, compile to JS.
- bad_user 13y ago> That said, the remaining 10% really do want something more. Yes, but those 10% are better served by going native. What's the problem in going native using the platform's native SDK? OH, if you're going to say that native apps don't run in the browser, well, the browser's inherent advantages over native are that (1) it runs everywhere, on every platform and (2) it's based on standards with multiple implementations. But NaCL for all intents and purposes is native to Chrome and not part of the web (it also doesn't run on ARM chips). NaCL will never be a standard accepted by either Microsoft, or Apple or Mozilla, because it's not portable enough and because it's so freakishly complicated that writing a spec for it is really, really hard and the jury is still out on its technical soundness. And sure, it's open-source, but that's not enough. So you know, those 10% that want more, can only find comfort in NaCL if they only want to target Chrome's Web Store, which isn't different from targeting an OS. But that's not the open web. For the open web, those 10% have no choice other than Javascript, which is why Asm.js is so awesome, because it exists.
- nashashmi 13y agoNaCL does run on ARM, but the same code will not run. Another version of the code will run.
- josteink 13y agoI'm not sure "intrinsically superior" is the right way to think about this. It's fast enough. It's compatible with the existing web. It's platform independent. It runs in any standards-compliant web-browser. That's four wins right there. It's fundamentally superior. End of discussion. That said, the remaining 10% really do want something more. They want to write targetted architecture-specific assembly, perhaps. If they do, they can go do it somewhere which isn't the open web. When I use a web-browser, me and my devices aren't going to wait for you to fix your webpage to support the architecture I happen to be running. We're going to go somewhere else. Imagine how impossible it would have been for early Macs and ARM-devices to enter the market if the web was already entrenched in platform-specific Intel x86 code. How many of those websites out there do you think would have been "fixed" in order to work on other platforms, years after the authors abandoned them? I'm guessing a tiny fraction. They didn't have to though, because the web is cross-platform. This is by design. We should thoroughly ignore Google's best efforts to reverse this with their proprietary NaCl. Why on earth would we want to change the best quality of the web now that it has already proven its value?
- haberman 13y ago> Imagine how impossible it would have been for early Macs and ARM-devices to enter the market if the web was already entrenched in platform-specific Intel x86 code. Are you aware that NaCl (the platform-specific version) is only enabled for applications installed through the Chrome Web Store? Chrome will not load NaCl modules from the web. All that is supported for the web is PNaCl, which is platform-independent. See: https://developers.google.com/native-client/dev/nacl-and-pnacl https://developers.google.com/native-client/dev/nacl-and-pna... So your hypothetical is not in danger of happening.
- josteink 13y agoOk. Fair enough. That said, that's not what the post I was replying to was suggesting. It was suggesting writing architecture-specific assembly code and putting it on the web. And citing that as a legitimate need which should be addressed by browser-vendors. Needless to say, as someone who supports an open, cross-platform web, I strongly oppose any such measure.