Search code examples
javascriptmultithreadinglanguage-featureslanguage-design

Would JavaScript fare any better had it been multithreaded


This is a follow up question to Is there a point to multithreading?

If JavaScript were multithreaded, would it fare better than the existing system? Would multithreading with one UI thread and other tasks in different threads (background) bring in greater responsiveness and efficient usage of resources?

Why did the designers of the language decide to stick on to the single threaded model despite the advancements in no of CPUs/machine and the need to simultaneously pull different content and data from different mechanisms. Why are they still ok with the way JavaScript timers work when multithreading can offer far greater accuracy?

I am not trying to pin down JavaScript as inefficient, rather learn how multithreading brings in value in comparison to complexity it introduces to programming


Solution

  • Brendan Eich (Mozilla's chief technical officer) talked about the complexity this would create in "Threads suck".

    His conclusion: "So my default answer to questions such as the one I got at last May's Ajax Experience, "When will you add threads to JavaScript?" is: "over your dead body!"

    Using web workers is the alternative.