On Mon, Jan 17, 2011 at 6:12 PM, Andraz <[email protected]> wrote:
> I want to develop multi core capable JS applications. Even if multi core > support is not all around us today it will be soon enough in the good > engines to think about it in advance. Hate to burst your bubble there, but there is a high amount of resistance to adding threads to js in browsers. I don't think I've ever heard vendor devs being positive about the idea. I'm just saying, don't get your hopes up on this :) However, with the coming of html5 also comes the webworkers api. This is almost like threading, except for the difficult debugging. The upshot about this is that it's unlikely you'll ever get a pesky race condition (maybe one of the most difficult types of bugs to fix, ever). And browsers are free to run webworkers on separate cores (not saying they do, but I'd expect so). Be sure to check that out :) > What is the best way to go about it and which way is the most > soon-to-be-parallelized candidate? > I guess you could simulate something like that with node. There are a few scripts that allow you to communicate with other node instances (unless you want to build this yourself, of course). I don't recall names, but either google or somebody on this list certainly will be able to name a few. With that you could probably at least simulate threads (sharing the parent environment). I did hear Ryan (the creator of node) say he will certainly not add co-routines to it though. > Event-based programming - don't call functions but call events on the > window object > Node is single threaded but uses a big event loop to be that way. > Extensive usage of web worker threads? How to go about DOM manipulation > from workers in this case? > Oh, you've heard of them :p Webworkers have overhead, be sure to test whether your app actually benefits from it. Small packages are usually not worth it. If you do use it, I'd advice you to create a message api of your own. Send json messages with an action and a payload. That way you could easily do manipulation of the dom/global/console as desired without too much obfuscation. Of course, it's only a matter of time before somebody releases a wrapper library to do this kind of messaging with webworkers easier (*hint*). > Is the async XHRequest single or multi-core? In other words: If I have a > quad core CPU and start 3 XHRequests at once, will the requests and result > callbacks run in parallel threads or serial in the same thread? > That I don't know and I don't want to take a guess either. - peter -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
