HackerTrans
TopNewTrendsCommentsPastAskShowJobs

stevecooperorg

no profile record

comments

stevecooperorg
·16 yıl önce·discuss
> You won't be writing code in the browser anymore

You could be. Impement a URL like http://mydomain/scripts/MyScript.bytecode. This is a page which compiles, say MyScript.rb into bytecode and delivers it back to the client. You get a new copy by saving a file on the server and hitting refresh, and there's only one interpreter to download.
stevecooperorg
·16 yıl önce·discuss
It would almost certainly be a good deal slower. Or at least, it would be if I wrote it.

I know cappucino (http://cappuccino.org/) works with a JavaScript language interepreter, so there are mature products out there heading along these lines.
stevecooperorg
·16 yıl önce·discuss
As people have commented, I'm suggesting writing a javascript function which takes pre-compiled bytecode; like so;

    function interpret(bytecode) {
        // stack machine implementation goes here
    }
And called like so;

   var bytecode = load("http://my.domain.com/myscript.bytecode");
   interpret(bytecode);
     
I'm not suggesting that bytecode is inherently slow -- just that I could take a great stab at writing a slow bytecode interpreter in JavaScript. ;)

So under this scheme, you could do a server-side compilation of any language -- let's imagine Pascal as an example -- and deliver it back to the client as bytecode. Now you've broken the browser dependence on Javascript. At the cost of a VM written in JavaScript.
stevecooperorg
·16 yıl önce·discuss
I'd also be interested in knowing. AFAIK, things like coffeescript compile to readable, plain JS. Can a relatively efficient system be made which interprets something more 'bytecodey' than readable JS;

eg,

interpret(['.maxstack 8', 'ldstr "Hello World!"', 'call void window.alert', 'ret']);
stevecooperorg
·16 yıl önce·discuss
I'd be really interested in seeing this develop. Define a bytecode interpreter (JSVM?) and push bytecode into it. Performance may be god-awful, but you'd be free to use whatever language you fancy.

Parchment is an example of the approach, implementing the z-machine VM in javascript. http://code.google.com/p/parchment/