Domain: asmjs.org
Stories and comments across the archive that link to asmjs.org.
Comments · 10
-
Re:can somebody explain
Without knowing anything about the particulars of this solution, a likely approach nowadays would be to take an existing emulator writen in C/C++ and compile it to JavaScript using Emscripten.
Emscripten produces JavaScript compliant with the asm.js profile, which is a subet of JavaScript that is easily optimized by the browser JS engine, allowing in-browser performance on the order of half of native speed. Given the age of the emulated hardware, this slowdown is not a problem.
You still have to emulate actual I/O devices in plain HTML+JavaScript, which for these presumably amounts to mapping JavaScript input events to a virtual keyboard, and using a HTML Canvas element to emulate the display. Even joysticks and gamepads can be supported in bleeding edge browsers.
TL;DR: By standing on the shoulders of giants, and adding a bunch of glue code.
:-) -
Nothing on the underlying technology?
asm.js is the underlying technology they used to port the games to the web. According to Wikipedia, "asm.js is an intermediate programming language consisting of a strict subset of the JavaScript language. It enables significant performance improvements for web applications that are written in statically-typed languages with manual memory management (such as C) and then translated to JavaScript by a source-to-source compiler."
-
Re:Works in Safari
If you change the user agent to Chrome - Mac. Seems fairly CPU intensive though, managed to get the fans on my MacBookPro spinning up fairly quickly. That could just be the WebGL implementation in Safari not being so crash hot though.
I don't know that Safari's JavaScript engine can optimize for asm.js yet, so I'd guess it's the JavaScript more than the WebGL. Asm.js JavaScript works everywhere, but Firefox and Chrome detect and optimize for asm.js specifically and get really high performance figures as a result.
-
Re:Maximum precision?
That's only true for fractions.
1+2 == 3 is always going to be true.
As is 123456789 + 987654321 == 1111111110You can absolutely express a 32 bit integer in a double with no approximation ever.
We rely on this in our lua scripting as a matter of fact.http://asmjs.org/spec/latest/ relies on this for the 32 bit integer parts of their spec.
Actually, you can go a lot further than 2^32 - all the way up to 2^53-1.
This is taken advantage of in non-asm.js places. See:
http://bitcoinmagazine.com/7781/satoshis-genius-unexpected-ways-in-which-bitcoin-dodged-some-cryptographic-bullet/And, you'll be happy to know (well, we were), that Mozilla is adding 64 bit ints to their JS as well, although when that'll be widely available, who knows.
-
Re:Standardize a VM interface instead?
Ever heard of asm.js ?
-
Re:Not as long as we have to write them in javascr
Auto-translated code is not going to look anywhere near that nice. For performance, it'll probably look more like ASM.js to work around Javascript's many difficult-to-optimize constructs.
-
Re:A version of Dart that compiles to asm.js?
While I appreciate efforts to improve Javascript ($DEITY knows there's a lot of built-in retardness, although personally I'd appreciate most if ECMA Harmony would finally be implemented - not holding my breath though as I like living), I'm not sure I really asm.js is the way to go. However, their typing system is "interesting" - but it doesn't go far enough. I mean, it's great that you can have "intish" and "doublish" values, but why stop there? Print stringish stuff to the console, define your own objectish values in an arrayish structure, manipulate them with functionish methods - the possiblities are endless(ish)!
-
A version of Dart that compiles to asm.js?
For those of you who don't know, asm.js is a subset of JavaScript that's meant to be easy to compile. In other words if you use asm.js the code your will work in all browsers, but should run faster in some. In that FAQ they say their compiled asm.js runs at about 1/2 the speed of C, making it roughly twice as fast as JavaScript V8.
Which is wonderful, except that JavaScirpt is a prick of a language, and so I'd imagine that asm.js is a tedious, prick of a language. But Dart compiled to asm.js - sounds like a marriage made in heaven.
-
Rube Goldberg
Let me get this straight.
They (the asm.js nutjobs and the vendors who trot along) are proposing to take programs written in C or C++, "compile" them to the fascist brother of Javascript (I won't call it a "subset" of the language because it actually works by adding boilerplate code) so that supported implementations can recognize that the Javascript source has all the boilerplate cruft in place and try to compile the damn thing back to machine code.
Rube Goldberg would be proud.
Besides, I can see the security chasms opening as we speak
-
Re:Javascript engine evolution
Ah, my mistake. "use asm" is a proposed Javascript feature:
... asm.js, a strict subset of JavaScript that can be used as a low-level, efficient target language for compilers. The asm.js language provides an abstraction similar to the C/C++ virtual machine: a large binary heap with efficient loads and stores, integer and floating-point arithmetic, first-order function definitions, and function pointers.
http://asmjs.org/spec/latest/
Also interesting:You could write your programs in Asm.js, but the idea is that you will use other languages that compile to Asm.js. This opens up the possibility of converting existing desktop apps to run in the browser. Emscripten, for example, is a compiler that converts the LLVM bitcode intermediate language to either JavaScript or the asm.js subset.