170 points · by patrickaljord · 13y ago · 115 comments
Few months ago by Brendan Eich: "Get your tums out, pal. We're taking PNaCl down for good this year with http://asmjs.org/. Cross-browser."[1] With the announcement of Unreal Engine and this, seems like he's one step closer to the goal. Now only JSC and Trident left...
I don't think that's accurate. We started work on asm.js only a few months ago; at the beginning, we had no idea if it would work, so we just threw around some ideas between each other. When we had something we felt could actually work, we immediately put it up on
https://github.com/dherman/asm.js
And worked on it there. asm.js has been discussed on IRC (#emscripten and other places), the emscripten mailing list, etc., as we further improved the spec.
About the middle last month, we got some performance numbers, and felt we could say something about speed, so I mentioned asm.js in my talk at mloc.js and other more noticeable places, but it was definitely not a secret far before that.
> relies extensively on engine quirks
That would be a bad bug in the asm.js spec. Can you please elaborate?
I think Mozilla would get a lot more benefit if people stop with the juvenile "You're going down!" adversarial mentality. If someone from the Dart or NaCL team had tweeted "2013 is the year NaCL and Dart destroy Javascript!" imagine the uproar. This is about exploring the solution space for solving technical challenges related to maximizing performance, helping developer productivity, and strengthening the Web, and there are many potential solutions. (I for one don't see the "Web" as Javascript, I see it as HTTP, URL, 'drive-by', indexability, transparency, platform independence and location independence. HTML, CSS, and JS are just particular concrete embodiments of those principles, but 30 years from now, they could be implemented in a radically different way)
I think asm.js is great for a slice of game genres, and I fully support it. The cheerleading and politics just isn't needed, let the code, benchmarks, and game demos speak for themselves.
As others have pointed out, Mozilla has been less than receptive when similar situations were reversed. I also know from working with the NaCl and PPAPI teams that they repeatedly reached out to Mozilla in an effort to publicly develop a mutually agreeable standard, but they were not well received. So, given past precedent, the way asm.js was introduced isn't necessarily bad, but it certainly feels a bit hypocritical.
>> relies extensively on engine quirks
>That would be a bad bug in the asm.js spec. Can you please elaborate?
Perhaps "quirks" isn't the right word for things that are idiosyncratic but legal either by standard or de facto convention. It's certainly an ingenious way to get backwards compatibility while basically defining a new IR, but it is a bit... quirky.
As I mentioned elsewhere, I think asm.js might really catch on. It could be the IR that finally becomes universal, in large part because your backwards compatibility strategy is so damn clever. That said, I also see a few obvious pain points that will need solutions:
* Reasonable debugging support (maybe just a metadata standard morally equivalent to symbol files)
* Threading (even just co-routines, it seems some behavior needs to be specified)
* Load performance (validation and code caching seem needed, which are very tractable but just mean more work)
Wow, where have I heard that before? ;)
It's a spec for a subset of JS with guaranteed AOT compilation — it's hardly one that needs to go through a thousand committees to get somewhere where all those concerned are happy. If you want to do AOT compilation, everyone basically needs the same subset. Indeed, the most contentious part of asm.js is probably how you isolate it off from the rest of the script. It's simply not a spec that defines very much.
And what engine quirks does it "extensively rely on"? If it relies upon anything apart from ES5, it's broken and the spec needs fixing.
Similarly, it's out of scope for it to deal with anything like code caching and threading — the former is depending on how you tackle it either implementation detail (see how Carakan and V8 implement it today) or something really quite radical to the platform (but not something that needs to be immediately tackled), and the latter is one solution to a broader problem (parallelism in JS). Neither seem like things asm.js should be rushing to solve.
An AOT compiled subset of JS is not in itself novel: this is not the first time it's ever been talked about, but what is novel (to my knowledge) is the idea of making compiler behaviour explicit for it, by having a token in code, along with isolating globals. Enabling AOT compilation is in many ways the "golden-grail", as although one must still be weary of compilation time (see SunSpider — many of the benchmarks complete in under 10ms, so you don't have the time to spend compiling them), the warmup time is currently relatively large.
Performance improved in Chrome on at least one Emscripten benchmark when generating asm.js code rather than the previous backend, without any further change to Chrome, probably because asm.js does a better job at formalizing the various assumptions that this style of code relies on.
Probably, but why? asm.js is supposed to be a target for compilation, but if you can run Node, you have a better target: actual machine code.
[1]: https://github.com/srijs/rusha/commit/e435ccdd709b6a3374879c...
[1] https://github.com/felixge/faster-than-c is a talk by a longtime node contributor on this topic.
Anyway I agree. People in the previous thread clamoring for NaCl, claiming asm.js isn't supported by other browser now look really, really foolish in hindsight.
I'm moderately happy the Web is moving in this direction. I'm glad Mozilla is moving it in that direction :)
Pepper for one is a pretty good reason IMHO
That isn't quite true anymore either, because of Web Workers and ParallelArray.
https://bugzilla.mozilla.org/showdependencytree.cgi?id=80186...
No, I don't care about backwards-compatibility. I care about the solution leveraging existing infrastructure and not being a hack.
Because it's a strict subset of javascript which is already cross-browser.
> The argument is moot since if Mozilla said that first about PNaCl (that they'd adopt it) it would be PNaCl that would be the cross-browser solution.
PNaCl is still not done, still not fully specified and still full of Chrome implementation details via Pepper.
> No, I don't care about backwards-compatibility. I care about the solution leveraging existing infrastructure and not being a hack.
Which would exclude PNaCl since there's no existing PNaCl infrastructure.
Isn't that one and the same?
This seems to be much ado about nothing unless and until it's accepted and assigned.
The engineer in my says, cool idea and judging by libuv [0] The joyent / node.js team seems to be open to abstractions, if help is offered.
Assuming the technical task isn't too expensive in terms of leaky abstractions or ripple, one has to ask the next question, if V8 works...why, would it be worth it?
https://github.com/zpao/spidernode
but then they dropped it.
Your suggestion is certainly a more accurate summary. (I'm on the Chrome Developer Relations team)
I am writing a blog post that condenses my feeling towards asm.js into something tangible.
I also would like to add that it still excites me much to see JavaScript to become faster and faster and that I anticipate real world JavaScript written by human hands to become faster in the future and I don't think we need AOT compilation shortcuts for that.
It's not from some random dude on the internet.
Very smart move IMO.
Edit: To clarify. To think that the devs here are interested means the Mozilla folks got the right idea.
I think WebGL/OpenGL will do nicely to create a game like Ikaruga (http://en.wikipedia.org/wiki/Ikaruga). It's probably one of the hardest, but most enjoyable games I've ever played and I think mobile/indie game developers will pull it off. If anything this opens up a new democracy in the previously restrictive world (if not outright closed as in iOS) game development for devices and consoles.
I think we're already going to see OpenGL ES 3.0 being implemented into WebGL within the next 2 years, and even if WebGL never adopts the full OpenGL (it has a lot of cruft anyway), keeping up with the OpenGL ES API's should be good enough (OpenGL ES 3.0, ES 4.0, ES 5.0, etc).
I was thinking the OpenGL ES will be the future most popular graphics API anyway (on any platform). It's just that Nvidia announcing full OpenGL 4.3 support for Tegra 5 kind've made me re-evaluate that. But if other mobile chip makers just stick with OpenGL ES, and WebGL does, too, then OpenGL ES should still become the most popular graphics API in the next few years.
It won't make it into asm.js anyway, but into the WebGL spec.
Why, did you expect AAA games on the browser?
One step at a time people, one step at a time...
Mobile games of the kind you get on an iPad, with 60fps are a perfectly good target for the web browser.
"Let's wait to land a patch until Jakob is back."
I filed Issue 2424 and so let me explain: my fix was a very hackish local way (not the way I'd really like to see it fixed) that just demonstrated how much of the performance can be gained.
A generic implementation is obviously preferred. I would like to do it myself but I don't work on V8 full time anymore so I can't dedicate my own time to it.
It was just the first thing that popped into my head when I read the comment.
Both approaches have their merits and drawbacks, I personnally prefer asm.js because of backward compatibilty and portability, but if we could avoid a 5 years fight about which is gonna bring near native perf in the browser, it would be absolutely awesome.
For me, its not that important, that every browser supports it. I have a large base of Business clients who have no problem, using whatever browser gets the job done best.
are you talking about the top-10 websites? let's take them one by one:
- Google. I don't think so, it's not even one of their major server-side languages now.
- Facebook. Likewise.
- YouTube. See Google.
- Yahoo!. I don't know anything about their server-side
- QQ.com, Taobao.com, Baidu.com. Given that the Chinese do not pioneer web platforms, I don't see why they'd do this.
- Windows Live. I know MS "likes" JavaScript, putting it in Windows and all, but it's not one of their major languages. It's not even their own :P
- Wikipedia. Would require a switch from MediaWiki or rewrite. While I'd very much like to see PHP replaced, it's currently doing it's job. I have a feeling the language does not matter much, MediaWiki itself is not very complicated.
- Amazon.com. Don't know.
Do you seriously see 5 or more of these turning to server-side JS?
- QQ.com, Taobao.com, Baidu.com. Given that the Chinese do not pioneer web platforms, I don't see why they'd do this.
From what I've seen and heard, this isn't true. Taobao in particular seems to be running on a pretty cool stack, and has contributed a lot with OpenResty, which is nginx with modules, LuaJIT and some goodness, backed by Redis, Memcached, MySQL and/or Postgres (inside nginx' event model).
Very unlikely; Amazon's backend is basically Perl talking to an SoA via an internal service definition language. A change to server-side JS would require a re-write of almost everything (which isn't unprecedented; the migration from a single giant C++ binary to the Perl system 10-odd years ago was such a rewrite).
Not saying you're right or wrong, but venerable technologies have a tough time dying quietly. Also most developers tend to be fairly conservative with what they choose especially when load and performance is concerned.
Err, people have moved on from straight parallel code. It's all about message passing and isolation now, which is something Javascript can get perfectly easily (and sort of already has).