I've not been posting on Slashdot much this week, because I've been trying out Soylent News, which is using (and old version of) Slashcode (with some improvements) and lacks corporate overlords. It seems to have captured most of what I like about discussions in Slashdot, although is suffering slightly from not having nearly as many active users (50 or so comments is still the norm and it probably needs 100+ to be sustainable).
If you've not visited ye
I should try it again. I found it frustrating on my 400MHz machine that gameplay became really slow when the map became complex (2-3 minutes for all of the AI turns to run really breaks immersion), but on a modern machine it's probably quite a lot faster.
Actually, thinking about how long I spent playing it, maybe I shouldn't...
With JavaScript, in most cases, the thing that users care the most about is load time. It's often better to use a simple AST interpreter for JavaScript than a clever compiler, because you can start executing the interpreter as soon as you've got the text. If you spend more than a few ms getting the JS ready to run, users notice even if the resulting code is faster.
The 'often' is the important bit here, because some pages use JavaScript extensively for animations, games, and so on. In this case, users will notice if it's slow. They'll also notice if it's eating all of the CPU on their mobile device and flattening the battery. It's better in this case to switch to an optimised compiled representation as soon as possible, because you can get away with running the game slowly for a few second (while it's typically loading assets and displaying splash screens anyway), but after that people notice.
In both cases, after a while you've got some useful profiling data and so you want to recompile and generate more optimised code (unless it's just doing menu animations and the JavaScript is using 1% of your CPU, in which case the compiler is likely to consume more CPU time than the compiled code will save). Ideally, you want to do this in the background, on another core (or, at least, on a lower-priority thread on the same core), because otherwise you're interrupting the thing that the user cares about to run the compiler.
[1] 'Interpreted' in V8 really means compiled with no optimisations.
Arithmetic is being able to count up to twenty without taking off your shoes. -- Mickey Mouse