3 ms·
This is profoundly false and I would have hoped you'd know better than to make an argument like this. There's an enormous gap between the CLR and (even bleeding
by kevingadd 11y ago
This is profoundly false and I would have hoped you'd know better than to make an argument like this. There's an enormous gap between the CLR and (even bleeding-edge) asm.js, not only in standard library feature set but in language feature set. MSIL is dramatically more expressive and the runtime offers a bunch of capabilities that still aren't available in the browser.
At present if you want to actually run a typical .NET application in the browser, you will have to boot and run an entire CLR implementation in asm.js, specifically because asm.js is not expressive enough to map typical CLR code to it. This includes things like reimplementing garbage collection because the browser still doesn't offer basic primitives like weak references. Even once you do that, there are specific things you won't be able to do - for example, weakly hold references to the DOM, or handle cross-language reference cycles.
For the record: I am the author of a .NET -> JS translator with near-complete CLR feature support, including unsafe code (pointers) and p/invoke. This stuff is not trivial, and much of the difficulty is a direct result of how anemic asm.js is as a compilation target, not to mention how pathetic the ES5 stdlib is. I'm also a participant in the WebAssembly spec process and I think you've misrepresented what it currently offers.
The web has a bright future but pretending it doesn't have problems does no good. It's honestly quite insulting for someone to claim that everything is OK here when I've been fighting hard for years to get the ecmascript and HTML5 feature sets moved forward so that the web can actually compete with .NET.
- pcwalton 11y agoI'm not claiming everything is fine. There are lots of problems with JavaScript as it stands. I don't think the differences between the CLR and JS are "substantive" in that they make it impossible to build working, performant apps. So far the main things you have cited are (a) the lack of WeakRef and (b) a bad standard library. I truly don't mean any "insult" here, but weak references do not strike me as something that makes the difference between an app working (and working fast) versus being incredibly slow. WeakMap covers lots of the use cases for WeakRef already. On the native side, Objective-C didn't even have weak references until iOS 5. As for the standard library, developers just add lodash or whatever they need; it's not ideal, sure, but it's just a question of whether the functionality comes bundled or whether developers add it themselves. If you add all the things you want to JS in order to get it up to parity with .NET by your definition, but do nothing to the DOM and rendering stack, you'll still have the performance problems people cite with mobile Web apps. On the other hand, if you do nothing to JS and fix the DOM and rendering stack, then I believe the Web will be able to compete with native. This is not to say we shouldn't improve JS, but it's not on the top list of things holding the Web back.