6 ms·
I've become increasingly convinced that a standardized VM in the browser that other languages could target would be the best idea. And we could forget that the
by adamnemecek 14y ago
I've become increasingly convinced that a standardized VM in the browser that other languages could target would be the best idea. And we could forget that the whole JS thing ever happened.
- jws 14y agoLLVM byte code in an OS secured jail/sandbox? The JIT is already there and BSD licensed so all the players can use it. You'd really have to trust your sandbox though. The API for what you what you can do out of your sandbox would be the hard part. Every capability you add to the API is also a lurking attack vector in each implementation.
- adamnemecek 14y agoMicrokernels in the browser to the rescue :-). But yeah, I had something like that in mind. I do realize that getting security right would be tricky, but I'm not sure if it would be that much trickier than say the security of any given JS engine. Since the semantics of said VM would be probably simpler, I would make the argument that getting the security right would be easier to do than the security of said JS engine.
- cbhl 14y agoIt sounds like you want Chrome's NaCl.
- lucian1900 14y agoYou're describing PNaCl.
- jws 14y agoThere was a company in the '90s that was working on a byte code representation of programs which was designed to be “optimally” small by encoding more at the AST level than the ASM level. There were papers, but they were acquired by Microsoft (I think) and vanished. Does anyone remember them? The papers would be interesting in light of this, and conveniently near the end of patent lifetimes if patented and solid prior art if not. Edit: Maybe I'm thinking of Michael Franz and Thomas Kistler's work on “Slim Binaries”. It matches the content if not the ambiance that I remember. It's been a while. My brain tapes could have print-through. “A Tree-Based Alternative to Jave Byte-Codes” http://www.ics.uci.edu/~franz/Site/pubs-pdf/C05.pdf http://www.ics.uci.edu/~franz/Site/pubs-pdf/C05.pdf “Adaptive Compression of Syntax Trees and Iterative Dynamic Code Optimization: Two Basic Technologies for Mobile-Object Systems” http://www.ics.uci.edu/~franz/Site/pubs-pdf/BC01.pdf http://www.ics.uci.edu/~franz/Site/pubs-pdf/BC01.pdf
- kibwen 14y agoI really can't tell what you're advocating here. It seems as though you're against JS in general, but I think you'll have a tough time arguing that JS isn't: 1) standardized, 2) a VM, 3) in the browser, or 4) a target for other languages.
- adamnemecek 14y agoJS is standardized. JS VM's are not. Also I'm not against JS per se, I've grown to appreciate the language for what it is, it's more the JS monopoly that I kind of dislike.
- dherman 14y agoNobody is going to agree to standardize the internals of their JS implementation. Competition for JS performance remains high, engines change their implementations all the time. Engine implementors do not want to, and should not, expose their implementation internals. Instead, what people really want is a standard semantics they can target that isn't tied to any one vendor's implementation details. That's the crux of a VM, and that's what asm.js is providing.
- adamnemecek 14y agoSorry, I did not explain my position accurately. When I said that JS VMs are not standardized, I was not arguing that they should be (that is in fact a terrible idea), I was responding to the poster above who said that since we (a) already have a JS standard and (b) browsers have JS VMs, that we already pretty much have what I was arguing for. I also agree that standard semantics is what people really want. Asm.js seems like an interesting project but one of the issues that (I like to think) the VM approach would solve is that the semantics could be more low-level. Why do I think that that is a good idea? Well ideally, one would not have to wait for different browsers to implement say websockets, but the websocket functionality could be simply implemented by the website as a library which would use (presumably secure) lower level primitives of the VM to achieve the websocket functionality. (If that sounds vaguely familiar to the microkernel idea, it's not just you :-) ).
- dherman 14y agoBest of luck... ;-P Seriously, asm.js already comes pretty close to a standardized VM at a low level. But we intend to grow it to include integration with structured binary data and GC, to the point where it'll provide very similar functionality to VM's like the JVM or CLR. The big real-world benefits of asm.js over a boil-the-ocean VM are that (a) the content is already 100% compatible and quite highly optimized in existing browsers and engines, and (b) it's far easier for engines to implement on top of their existing technology. The biggest downside is that the syntax is weird. But that's just not a big deal for compilers. They can generate whatever weird syntax they want. You could even implement your preferred bytecode format as an IR and compile that to asm.js if you wanted, but I'm not sure compiler-writers would even care that much. They'd do just as well to have IR data structures in the internals of their compiler, without needing a special surface syntax for it.
- smosher 14y agoI am getting the feeling that marketing asm.js needs to emphasize a few things: - It is JS. - It is effectively an IL for every JS backend. - It is constructed to contain proven equivalences with familiar models in advance. To me these points alone suffice shut down the standard bytecode idea by either meeting or exceeding it everywhere. Finally: - Today. Nothing needed breaking to build it. You've got your eggs and omelet too. Edit: format.
- adamnemecek 14y ago>> "To me these points alone suffice shut down the standard bytecode idea by either meeting or exceeding it everywhere." Today
- tinco 14y agoI thought we had made a standardized VM language called Javascript so we could forget this whole activeX thing ever happened..? Not that I disagree that a VM would be very awesome, but it should take as many clues from the collected knowledge of Javascript security as possible, obviously just hooking your 'sandboxed' VM to the browser doesn't cut it. As demonstrated by SUN's Java applet :)
- chc 14y agoForcing everybody to use the a ubiquitous, homogeneous VM implementation is probably not going to work. Browser makers like being able to improve their implementations on their own at a brisk clip. Also, while standardization is a good thing, competing implementations are also a good thing.
- adamnemecek 14y agoVM standard != VM implementation standard
- chc 14y agoYou actually said "standardized VM," which I took to mean "one VM upon which everybody standardizes." But even now, it's unclear to me what you mean to be standardized about this VM if not its input and output (as we already have that with JavaScript VMs) and not the implementation. What are you asking for?
- adamnemecek 14y agoA VM with standardized input and output is exactly what I meant. Nevertheless, the underlying implementation of said VMs can still differ but they would all implement the same bytecode standard (similarly as both HotSpot and Dalvik both implement the JVM bytecode standard).
- chc 14y agoBut JavaScript VMs already have standardized input and output. It is not a bytecode, but it is standardized input with standardized output. So we already have what you want except that the input format is different than you envisioned. It seems to me that's the whole idea behind asm.js — they're defining a subset of the language that can be implemented very efficiently with precise low-level semantics so that we get most of the benefit of a bytecode without throwing out all that we have now.
- dysoco 14y agoI agree... I don't know who thinks having Javascript as "bytecode for the web" is any good: Even other languages(Fay, Clojurescript) need to compile to JS. Wouldn't it be better if we had a standarized, fast, language that other languages like the aforementioned can target?
- chc 14y agoWhat do you think JavaScript is? It's a standardized, potentially fast† language that other languages can compile to. † No language is inherently fast. C can be slow (see CINT) and at least a subset of JavaScript can be fast (see the OP).
- azakai 14y agoThat is exactly what asm.js aims to be: a fast target to compile to. As a bonus, it is fully backwards compatible and portable too.
- dysoco 14y agoOh interesting, hope it succeeds then!