ecmascript should support multi-threads

Quildreen Motta quildreen at gmail.com
Sun Jan 12 09:26:26 PST 2014


The idea of having shared mutable state in a language is a horrifying one.
I'm glad JavaScript isn't heading in that direction.

We *do not* need threads for parallelism, and scaling in to use multiple
cores. In Browsers, we can already have isolated parallelism through
WebWorkers, which means that we can safely use all the cores in a machine
without the need of locks, and the possibility of deadlocks. Currently,
communicating between these workers is slow because you need to pay the
price of serialisation, but they work well for things that don't need to
communicate so often.

Value classes are planned for ES7, once they're in WebWorkers will be able
to efficiently share data between different workers, without the need for
locks and the possibility of deadlocks. This is both safer and faster (due
to the immutability of the data). As soon as v8 supports Value Classes,
Node will be able to leverage then to make parallelism a no-brainer. Until
then, the cluster module is the best you'll get.

Note that this will also allow us to get the same distributed semantics as
Erlang/OTP: isolated processes, crash-only systems with custom supervising
strategies. And that's a really awesome thing for writing robust and
reliable distributed/parallel systems :)


On 12 January 2014 13:59, Andrea Giammarchi <andrea.giammarchi at gmail.com>wrote:

> if you are talking about node.js there have been recent improvements to
> the cluster module.
> I've used cluster even in Cubieboard2 and it works quite well using as
> many resources as possible if specified.
>
> Maybe that won't make JS like Java (thank Gosh!) but combined with linear
> and async callbacks it does a very good job.
>
> http://nodejs.org/api/cluster.html#cluster_cluster
>
> Hope this helped,
>     best regards.
>
>
> On Sun, Jan 12, 2014 at 5:26 AM, 紫诡 <1511569466 at qq.com> wrote:
>
>>       hello, now javascript engine don't support multi-threads , because
>> it's nouseful in brower.
>> but, if engine in server, like node.js , it's will be need. although, we
>> can use non-blocking
>>  API to do it, but it can't support multi cpu env well good.
>>     so , if javascript add SYNCHRONIZED keyword into, and hava Thread
>> Manager API , it will like Java Language
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
--
Quildreen "(Soreλ\a)" Motta
(http://robotlolita.github.io/<http://killdream.github.com/>
)
*— JavaScript Alchemist / Minimalist Designer / PLT hobbyist —*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140112/0b632632/attachment.html>


More information about the es-discuss mailing list