Subj : Re: Javascript for scripting a computer game To : netscape.public.mozilla.jseng From : smileyhamster Date : Sat Nov 20 2004 03:34 pm Igor Bukanov wrote in message news:<419E3232.7050804@fastmail.fm>... > For numerically intense code the interpretation mode can indeed run up > to 10 times slower, but for many simple scripts/functions that mostly > access properties, call other functions and especially access Java > objects the difference should be minimal. Yes, some basic benchmarks showed me it shouldn't be a bottle-neck. For most game scripting, you would expect basic to no numerically intense code at all and just calling some functions of a heavily specialised library. > http://cocoon.apache.org/ uses code like that to pause/resume > server-side scripts among other thinks so you have to thank Cocoon folks > and in particular Christopher Oliver who implemented original > continuations support in a Rhino fork. I actually managed to find a link to Cocoon when I was searching for ways to serialise Java threads. I originally tried to script my game with Java objects which would pause and resume with Java threads. This meant multiple threads (although none had to run with even simulated concurrency) and poor performance. I started trying out the excellent Rhino library when I found the snippet of example code for the upcoming continuations feature. The example code wasn't the best however and doesn't really hint at why coninuations are so useful, such as in game scripting and server scripting. > The idea of shared scopes is to define standard library objects, JS > functions and any other objects that suppose to be read-only in a shared > scope and then for each script give a private scope that points through > its prototype to the shared scope. Then all variables that the script > defines would be stored in the private scope. To ensure read-only > access you can seal the shared scope to prevent its modifications using > ScriptabkleObject.sealObject(). Great, that sounds exactly what I need. Thanks for all your help! .