Showing posts from August, 2010

Logo in JS with Web Workers

One of the most common requests I get for my Logo in JavaScript page is "can you watch the turtle draw?" This turns out be rather tricky. As currently written, the Logo interpreter converts Logo procedures into JavaScript functions, and evaluation takes place using the JavaScript stack. The "evaluate" step of the REPL is a single JavaScript call, which yields a JavaScript value. It would be possible to change the interpreter to not use this approach, but I'm rather fond of it, and it leads nicely towards converting the interpreter into a compiler. (It's most of the way there already, although in a non-traditional way.) And unfortunately, JavaScript in the browser executes in the "UI" thread so there's no opportunity for the display to update within the evaluation of a JS function. When running a Logo procedure or program the display freezes and you need to wait for the entire drawing to complete before you see the results. At least, tha