I have experience of porting JS code from one environment to another. First I was using Delphi Application with MS Active Scripting and MS JScript Engine then moved to nodejs on linux, then back to windows on nodejs, and still have JS code originally written for MS Active Scripting. With nodejs vm module you may create needed context. I also was successfully using socket.io and code on top of it with MS Active Scripting based application by implementing simple WebSocket wrapper to Delphi component.
Ok
this intArithm variant (w/o memoization) for NodeJS is 6 times faster (0.54 sec)
comparing to naive
function intArithm(){
var
max_a0 = +process.argv[2],
longest = 0,
max_len = 0, a0,len, a,z;
for(a0=1;a0<=max_a0;++a0){
a = a0;
len = 0;
while( a != 1){
len++;
z = a >>> 1;
a = (!(a&1))?z:(a+z+1);
}
if(len>max_len){
max_len = len;
longest = a0;
}
}
console.log(max_len,longest);
}
the problem was with division by 2 operation which is not integer in js. So replacing it with shift >>> makes the trick.
Formula optimization gives additional 200 ms.
And I doubt memoized c or lua variant will be 6 times faster than non-memoized. As it is not that linear.
it says it is traveling at 1/10 th of light speed. it takes less than minute to get to Mars in pixels, but from other sources I know it takes 13 minutes for radio signal to get to mars. Something does not play here.
This is at the closest pass, when Mars is ~0.5 AU away from the earth; that's 4 light minutes.
It takes 13 minutes from light to get to Mars from the sun, and I think that'll also work out to be close to the "average" time from Earth to Mars.
In any case, you're right that apparently the demo exceeds the speed of light at some point, because it doesn't last for 4 minutes. Someone else suggests that the motion be interpreted as a fast pan rather than a physical motion, which is how this should have been implemented to not contradict the laws of physics. :)
An didn't know about this, looks great. Would you be interested in helping me write an add-on for better-require? Anyways, I'll try it out and see how it works out.
No you cant. It is NodeJS module referring node-ffi - module allows you to call dynamic libarary functions w/o making your own binary module. So it may be used with NodeJS under Windows. For example you may access COM ports directly from JS. Or you may send messages to other Windows to manipulate them.