I've had people come to my blog searching for how to do threading in JavaScript. Unfortunately, I haven't found a way to do true threading in JavaScript. The closest solution I've found involves creating queues that hold work items. Every 250ms (or a developer-defined interval), the queue checks if work needs to be done and starts a task if none is already running. This approach mimics threading. Check out my AJAX Tagger 2.0 for a working example. If you have any insights on true threading in JavaScript, I'd love to hear them!
I'm exploring ways to implement continuous polling of a resource and event dispatching based on its state in JavaScript. Are worker threads, or something similar, achievable in JavaScript? Currently, timer-based triggers seem like the most viable option. Is this an acceptable approach, or are there more efficient and appropriate alternatives?
In this first installment of a series about my AJAX application journey, I'm sharing my initial success: learning to think asynchronously. The current app takes user-entered text, sends it to a Yahoo web service (via a local Perl script), gets "interesting" words, and then makes synchronous calls to Technorati for tag counts. This synchronous approach locks the browser, especially with multiple tags. The next version will use a queue and multiple asynchronous XMLHttpRequest objects managed by a thread manager to avoid browser lock-up. This will create a more responsive app where results appear as they become available. Key requirements for v2 include full asynchronicity, XMLHttpRequest management, a generic work queue, background task indicators, and a non-blocking UI. I'm also planning to develop a reusable object model.
My first foray into Ajax was a mixed bag, yielding both valuable lessons and frustrating setbacks. On the plus side, it sparked a deeper understanding of asynchronous coding, cross-browser compatibility (especially between Firefox and IE), and the potential of APIs like Yahoo! and Technorati. It also reignited my interest in Perl and prompted reflection on my blogging practices. However, the application fell short in several areas: it lacked search functionality, didn't reduce bandwidth, had a poor visual design, and wasn't user-friendly or impactful enough to generate feedback or traffic. Moving forward, I'll share my design process and desired improvements, starting with a clear requirements document. I'm eager to learn from this experience and create a more effective application.