Proposal of Multithread JavaScript

Leo Dutra leodutra.br at gmail.com
Fri Nov 4 10:52:27 UTC 2016


Isiah, the only serialization, or at least heavy one, in DOM is .innerHTML
and some other textual stuff. Appending moves pointers and references in
the internal DOM representations (a real problem in old browsers like IE
was this representations ran in another host Engine).

Appending nodes are blazing fast... And is structural code, not evented as
the bad message passing of spawned processes in Node or Web Workers.

Isiah, I'm used to cluster, maybe more than I'd like.

I'm very used to Java threads, and now on Java 8 a Runnable is a Functional
interface implementation (means in Java that Runnable.run() became a simple
lambda function). This is more than enough similar to what a JS function
could either be on a thread API.

If Node abstracted process as a kind of Host object like a DOM Node,
messaging would be lighter and probably serialization would be done at C
levels, not on JS strings / stringify level.

Java Threads are part of a scope, Node clusters are not. This implies
speed, scoping and control differences enough to say Workers/clustered
processes are way different from what I propose.

And more, cluster process or process spawn or Web Workers require  a
particular separated JS ( or you will do dirty stuff putting run JS
together with massive  ignored JS).

A thread would be as simple as:

thread.run( (thrd) => console.log(thrd.id) )

A simple "callback"/ stream/ whatever you call run out of Event Loop. A
while(true) would not lock any other JS operation.

That's the most powerful part of thread spawn and to allow JS devs to do it
is much. This with indication for components, like XHR, to run callback in
a threaded function out of Event Loop.

Event Loop should do all that Node does and People say it does good: io
messaging and no aggregation / loop intensive stuff.

There's no reason to care with mutability since callbacks mutated values
today and most new js devs already think it is running on a parallel
process (many many people will even call you crazy if u say).

Again, think in a function as any callback today, but running out of the EL.

I can't make a more realistic metaphor.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161104/8358259b/attachment-0001.html>


More information about the es-discuss mailing list