Open Bug 1385876 Opened 2 years ago

Threading coverage on MDN

Categories

(Developer Documentation :: JavaScript, enhancement)

enhancement
Not set

Tracking

(Not tracked)

People

(Reporter: cmills, Unassigned)

Details

We got this on IRC a little while ago:

"Hello, do we need an article to explain threading for JS? This article, https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers, explains Web Workers running via background threads. But what are threads? All we know is that JS runs in a single-threaded fashion, but it isn't clear to me whether there's multiple threads or not.

Adding to the fact we have "background scripts" for WebExtensions, it had confused some developers in the concept of "processes running in the background". Are background scripts in WebExtensions similar to "background threads"? I wished there is an article that goes into detail on this.”

Do we have anything anywhere that covers threading/background scripts/worker threads on MDN? If not, would it be worth writing up a short article to cover this concept somewhere? A glossary entry at least?"

I talked to Florian about this, and he responded like so:

"It would be nice to come up with an article that puts the Event Loop, Web Workers, and Shared Memory into broader context and does comparisons to other languages where threading exists.

For the event loop the relevant MDN JS page is https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop
And this talk https://www.youtube.com/watch?v=8aGhZQkoFbQ

For web workers we have the article you've mentioned and for Shared Memory there is a hacks post by Lars
https://hacks.mozilla.org/2016/05/a-taste-of-javascripts-new-parallel-primitives/ and more by Lin I think.

Oh and https://stackoverflow.com/questions/2734025/is-javascript-guaranteed-to-be-single-threaded/2734311 is also interesting.

This is one of these topics that really needs some good research and expertise to actually write something up that is useful."

We ought to write something about this if we can find the time at some point in the future.
You need to log in before you can comment on or make changes to this bug.