(Pour info Native Client (NaCl) de Google a le meme objectif que asm.js cf http://asmjs.org/faq.html)
we don’t really see Dart and Native Client as competing technologies; they are very, very different and Dart is a scripting programming language that is very immediate; you can write your code and you reload your page and its right there, and Native Client is a different kind of technology and it’s great for translating C code to something that runs in your browser. It’s very different, at the core of it.
La question qui vient ensuite a l'esprit est pourquoi ne pas utiliser asm.js en tant que bytecode pour Dart ?
La reponse ici :
Well the problem is it doesn’t work. [...] several companies have tried to do multi language VMs and the problem is that [...] there’s always compromise you have to make. [...] if you are implementing C# or Java, you will have basic types, right? You will have ints and doubles and longs [...] in JavaScript you have (削除) all updates (削除ここまで) objects everywhere and it’s very hard to reconcile these two worlds. So if you do a VM based on basic types it’s pretty much impossible to make it run fast if you want to implement JavaScript — and the other way around basically.
[...] if you try to make an implementation of JavaScript, it will be falling into the category we talked about before – dog slow — it’s just not fast.
Why didn’t Google build a bytecode VM targetable by multiple languages including Dart?
- Google already works on a multi-language bytecode: LLVM bitcode in PNaCl.
- Even if a bytecode VM is specialized for Dart, a language VM will be simpler and faster because it can work under stronger assumptions—for instance, a structured control flow. These assumptions make the implementation cleaner and optimizations easier.
- A general-purpose bytecode VM would be even larger and slower, as it generalizes assumptions and adds functionality that for Dart is dead code: for example, multithreading with a shared heap.
- No bytecode VM is truly general-purpose; they all make assumptions that privilege some class of languages. A language VM leaves more room to improve the VM and make deep changes to optimization of the language. Some Dart engineers wrote an article talking about the VM question in more detail.
Why not compile Dart to ASM.js instead of building a specialized VM?
The subset of JavaScript that ASM.js targets does not match what dart2js needs. For example:
- dart2js needs to verify the number of arguments match (calling convention).
- dart2js needs to do bounds checks.
- dart2js forbids unsafe accesses to non-existing fields.
[^] # Re: Petite digression sur asm.js
Posté par tanguy_k (site web personnel) . En réponse au journal Normalisation du langage Dart de Google par l'Ecma. Évalué à 3. Dernière modification le 28 décembre 2013 à 03:47.
Il y a autant de similitudes entre asm.js et Dart qu'entre le bytecode de la JVM et le langage Java.
La reponse a deja ete donnee ici :
(Pour info Native Client (NaCl) de Google a le meme objectif que asm.js cf http://asmjs.org/faq.html)
Cf http://javascriptjabber.com/008-jsj-v8-and-dart-with-lars-bak-and-kaspar-lund/
La question qui vient ensuite a l'esprit est pourquoi ne pas utiliser asm.js en tant que bytecode pour Dart ?
La reponse ici :
Plus d'infos dans la FAQ de Dart :