For example, lets say a function doesn't mutate any state outside of the function itself (all new objects stay in scope and it doesn't touch class level objects.) It seems to me that would be a perfect function to target to asm.js. In that case, the only thing that really matters is the output of the function. GC isn't a big issue because at the end of the function everything should be freed up anyways.
>> For example, lets say a function doesn't mutate any state outside of the function itself (all new objects stay in scope and it doesn't touch class level objects.) It seems to me that would be a perfect function to target to asm.js. In that case, the only thing that really matters is the output of the function. GC isn't a big issue because at the end of the function everything should be freed up anyways.
>
>
> Note that asm.js doesn't currently support strings or other objects either. Or closures or methods. Or external functions of any sort except for a specially configured set of bindings.
>
> At least in its current form, I think that means the set of Dart functions that could compile to something asm.js-safe is actually surprisingly small.
And note that V8 people were able to optimize some of the patterns that are common in asm.js without actually resorting to recognizing asm.js. Or at least that's my interpretation of what was said at IO keynote. Other JavaScript implementers should take this as an example, instead of inventing crazy JS subsets, if you ask me.
LT
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
And in Chrome, too! Because Chrome probably will start supporting asm.js anyway.
Alice has to take some of her JS, hand-rewrite it in C
Alice has to take some of her JS, hand-rewrite it in C
Good grief! Poor Alice. Stuck translating one error prone legacy language
to another error prone legacy language in order to get some performance from her shiny new browser.
If that happens, Felix is in a happier place: his Dart code will automatically get faster if it follows the rules the compiler needs to generate optimized JS. Alice has to take some of her JS, hand-rewrite it in C (no one's idea of a fun time), and then build her own bridge layer so her existing JS code can talk to the emscripten-generated asm.js code.
> Suppose Alice and Felix are competitors. Each wants to write a version of some app to run in all browsers. App requires some heavy computations as a part of it (maybe even small part, but critical for performance).
> Each has a choice: write in dart, or write in javascript+ (C -> asm.js)
>
> Now assume dart by itself is very fast, and doesn't need any link to low-level languages to be fast (this is yet to be proven, but suppose so). When Felix writes the whole thing in dart, his program runs very well in Chrome. But in Firefox... it's not speedy enough. Because javascript generated by dart2js doesn't utilize performance benefits of asm.js
>
> At the same time, Alice writes in javascript+C. Her code runs very well in Firefox. And in Chrome, too! Because Chrome probably will start supporting asm.js anyway.
Felix will probably finish his program a lot sooner than Alice (if we assume feature parity), meaning that Alice have effectively lost before she even began. And if we accumulate a critical mass of such Felixes, other browsers will have to start looking at Dart more seriously.
LT
> I do not think so.
> As I had mentioned, the point is not to write Javascript like code using asm.js.
To me, it looks like that for a lot of people, this is exactly the point ("ES6 will make the language usable and asm.js will make it fast"). They are wrong, but they don't know it yet.
> The point is to use existing Fortran or C++ libraries or Lua code or whatever. The Unreal game engine is already already.
That's right. It's also different from the original scenario.
> Depending on how asm.js evolves and defines its own API standard (maybe concurrency model including C++11 stuff), this could change the browser and server world.
This is what we should be speaking about. Dart still needs to mature, which will slow it down, while JavaScript is already a mature(-ish) language and they can focus on adding the important features (generators in ES6, anyone?). Parallelism in Dart is still in its infancy, async is still hard, JS interop still feels heavy and kludgy. We need a killer selling point (productivity? Performance? True, but too abstract), but before we get to it, we need to work through the boring parts. In the meantime, JS people can easily surpass us.
LT
To me, it looks like that for a lot of people, this is exactly the point ("ES6 will make the language usable and asm.js will make it fast"). They are wrong, but they don't know it yet.
The ES6 syntax (with TypeScript style ":" annotations) will actually be nice to code in.
A subset will be optimizable - implementors will do this.
The ES6 syntax (with TypeScript style ":" annotations) will actually be nice to code in.Yeah, when you forget today's JavaScript. The nice parts of ES6 are almost an entirely new language.
A subset will be optimizable - implementors will do this.They are doing it already. The problem is that noone really knows how the subset looks like. If you hit the sweet spot, you are fine -- but it's very easy to get out of the borders without even realizing.
--
I believe that asm.js currently runs at roughly half the speed of native code (2x the time).
Optimized Dart code (typed_data) apparently beats Java, so we can expect something like 1.2x the processing time of native code.
I'd rather have the Dart team concentrate on the Dart VM than on some doubtful JS-subset cross-compilation.