3 ms·
The reason why Erlang does this, is that in an event-loop based system, anything that blocks breaks everything. The Erlang solution is to launch untrusted C co
by davidw 14y ago
The reason why Erlang does this, is that in an event-loop based system, anything that blocks breaks everything. The Erlang solution is to launch untrusted C code in a separate process and communicate via sockets.
I imagine that Node faces a similar problem with "untrusted C code".
- ibotty 14y agoi am familiar with erlangs ports. why shouldn't the same work for node? (and btw: cryptography might take a big computational chunk. it's hard to write cpu-intensive stuff in node's callback style. but i guess the person(s) doing it will sort this out.)
- davidw 14y agoI'm just explaining one motivation for wanting to be "pure". Node could certainly do something like what Erlang does. Erlang has, in the past, also gone the 'pure' route. IIRC, they had their own slow/limited regexp implementation, for instance, so that it'd run in the VM and not block.
- ibotty 14y agooh. and erlang is not event-loop based. it has preemptive multitasking for its threads. so it is not as necessary in erlang than it is in node.
- davidw 14y agoBeing multi-threaded is a relatively recent thing for Erlang. And IIRC, it only starts enough of them to cover all the system cores. It has preemptive multitasking for its "processes", but seeing as how those are all in the same Unix process, and time is allocated to them via Erlang's own virtual machine, calling out to something in C that blocks would be a problem for Erlang. Erlang, at a basic level, is event based, and this kind of protection is necessary.