
Originally Posted by
thinus
How will this be used and what is the benefit? I am struggling to wrap my head around it. I would have thought that each instance of the software will take keyboard and mouse input, process the input and send keyboard and mouse messages onto the registered applications.
The networking aspect would simply receive keyboard and mouse input from a network connection as well as from Windows keyboard and mouse hooks. Why is it necessary to send pre-compiled scripts across the network?
I'll try to illustrate one of the main issues with an example using HKN2 syntax.
Code:
function MyFunction ( MyVar )
{
sendto ( 192.168.1.102 )
{
MyVar = MyVar + " all folks.";
Print ( MyVar );
}
}
The function executes on the local machine. The instructions in the compound block (inner curly braces) execute on the remote machine. How does the value of MyVar (which only exists in a stack on the local machine, it's not in a script on either machine) get to the remote machine and bind into the code there?
Seems to me that regardless of how this is implemented, the remote machine has to receive the following information in some form. The form doesn't matter -- it can be source code or compiled code -- but the remote has to receive the following info. (I'm making up a value for the variable. In real life the value would be whatever is in the local stack at runtime.)
Code:
var MachineGeneratedVar = "That's";
function MachineGeneratedFunction ( MyVar = MachineGeneratedVar )
{
MyVar = MyVar + " all folks.";
Print ( MyVar );
}
I think it's useful to think of the problem in terms of the above transformation. The transformation is a sort of functional spec for what the program has to do in some way or other.

Originally Posted by
thinus
Why not just push the text script to the 2nd machine and pre-compile it on the 2nd machine instead of sending compiled code over the network?
I'm going to skip over the "pre compile" part of your suggestion because it's not the main point, and also because Mojo has to assume that the local PC loaded the script hours ago and only just connected to the remote PC a millisecond ago. I'll just focus on the comparison of text vs. byte code.
The main point is whether Mojo could "just push the text script." Well, it can't simply push the original text script because the fragment of the original script looks like this:
MyVar = MyVar + " all folks.";
Print ( MyVar );
That's just a fragment. It won't compile or run on its own because, for one thing, MyVar isn't initialized. The fragment has to be expanded and transformed in some way before the remote compiles it. It has to be turned into the second example above, or something equivalent.
So we're not really comparing "push as written" to "do extra work." We're comparing two kinds of extra work.
If the program sends text (e.g. the second example above) to the remote, the local copy of Mojo must:
1. At compile time, create machine-generated functions in source form, store them somewhere, etc.
2. At compile time, put instructions in the compiled code that tell the interpreter to fetch the appropriate machine-generated-function-in-source-form and do the rest of the things on this list.
3. At run time, look up the value of MyVar in the stack.
4. At run time, create a new piece of source code that defines MyVar as a global variable and initializes it with a literal which has the same value as the value of the run-time variable in the local stack.
5. At run time, combine the two pieces of source code (variable definition and machine-generated function) and send them to the remote.
Connect With Us