4 ms·
But all of these just compile to Javascript in the end, right? I long for the day where we just have a "Browser VM" that we can all compile to instead of compi
by flyinRyan 14y ago
But all of these just compile to Javascript in the end, right? I long for the day where we just have a "Browser VM" that we can all compile to instead of compiling to a high level language.
- jashkenas 14y agoHere's an article by the Dart team that describes why the JavaScript VM (or the Dart VM) may already be the "Browser VM" you're looking for: http://www.dartlang.org/articles/why-not-bytecode/ http://www.dartlang.org/articles/why-not-bytecode/
- flyinRyan 14y agoAll of their justifications seem to have a language specific VM like the JVM in mind. If you made a strategy of a "platformless x86" approach you might be able to overcome a lot of this stuff.
- sethladd 14y agoYou might be interest in Portable NaCL (aka PNaCL). http://www.chromium.org/nativeclient/pnacl http://www.chromium.org/nativeclient/pnacl
- phpnode 14y agoHonest question - what can you do with bytecode that you can't do with javascript? Modern javascript is fast and ubiquitous and is clearly not going away anytime soon. Isn't the human readable nature of javascript more suitable for debugging anyway?
- olavk 14y agoSome features typical of VM languages, like "goto" makes it more appropriate as a compilation target, because lots of higher-level control structures kan be compiled to gotos. Of course goto could also be added to the JavaScript language as is, but then we have a conflict since goto is nice in a low-level language, but discouraged in higher level languages. This conflict of interest in language design does not exist when the user language is seperate from the VM-language. I agree with your point though.
- pcwalton 14y agoThe Relooper is good enough that the lack of goto isn't an issue in a practical sense these days.
- politician 14y agoThe Emscripten Relooper algorithm "takes basic blocks of code - chunks of simple code, at the end of which are branches to other blocks of code - and generates high-level structure from that using loops and ifs." http://mozakai.blogspot.com/2012/05/reloop-all-blocks.html http://mozakai.blogspot.com/2012/05/reloop-all-blocks.html
- pcwalton 14y agoThat's my point. The Relooper does a good job with vast majority of code that you might conceivably want to compile to JS, making the lack of goto not a problem in a practical sense for these compilers.
- politician 14y agoHah, sorry, I didn't know what Relooper did, so I posted a comment describing where to find out about it for other people.
- olavk 14y agoA VM is still a specific language, it just has a binary syntax. All VM's make tradeoffs which means they are a better fit for some languages than others. The fully language neutral VM does not exist. Given that, we might as well consider JavaScript a VM which just happen to have a text-based rater than binary source. A VM is therefore not necessarily an improvement on JavaScript - it has to be a better VM than JavaScript, and nobody have designed that yet.