I’d like to see the ability to make much more user-friendly UIs, but it’s quite limited when you hit the button and the page freezes while the whole script executes. First off, the page should be allowed to update (progress bar!), and also there should be an easy way to ask the user for continued input (IE, a custom browser could be created).
I’d do some looking at this myself outside of EteRNA specifically, but I honestly don’t know how it would work with how the interface might make the situation different from normal page scripting.
The Eterna scripting environment _is _a Web page. Web pages don’t ask for input from the user, they respond to input from the user. So if you want an interactive Web page, you add event handlers to handle (i.e. execute code in response to) user input.
A trivial example: copy and paste the following script into the code window and click on Evaluate.
Javascript is inherently single-threaded; that’s why there is no need for synchronization primitives in the language. But that doesn’t mean you can’t get the end result you are looking for.
The standard method used to be to break up the long-running work into smaller pieces. Each piece would
Do some useful work, then
Create a timer event that would kick off the next piece in the near future.
This works because the Javascript interpreter can process any pending user input events before the timer kicks off and starts the next piece of the long computation.
In HTML 5, there is a concept of Web Workers. A Web Worker is implemented essentially by starting up a new Javascript interpreter instance. The main program can get results from the Web Worker by creating event handlers to respond to messages sent by the Web Worker.
I did a quick check to see if the Eternascript environment supported Web Workers by running