3 ms·
The JS spec says nothing about threads or coroutines, just like the C spec says nothing about them either. That doesn't mean that they are incompatible with the
by olegp 12y ago
The JS spec says nothing about threads or coroutines, just like the C spec says nothing about them either. That doesn't mean that they are incompatible with the language. In fact, real multi-threaded JS code runs just fine on the JVM for example.
It works fine with the latest Node for me. Fibers relies on libcoro which has only had minor updates over the past four years.
I'm not sure where you're seeing this code sharing. In practice the only code that is shared is utility methods that don't do any I/O, so whether you use fibers or not makes no difference.
In fact, Meteor, being the framework that is pushing the boundaries of code sharing between client and server, uses fibers on the server.
- tjholowaychuk 12y agoI'm still curious about a js engine that supports coroutines better (fiber's stacks are pretty huge), it would be interesting to start fresh without all the legacy baggage that node has now.
- olegp 12y agoOne could fork fibers and have smaller stacks and even make their size dynamic, but actually the number of active fibers per process has been fairly low in all our use cases so stack size was never a concern. The more interesting problem is that of running multiple processes in parallel so you can saturate the increasing number of cores, while retaining low jitter and having a sensible end user API. My co-founder alexlamsl and I are actually working on something akin to Scala actors for JS that is portable between the browser via Web Workers and the server using Node and Common Node (https://github.com/olegp/common-node https://github.com/olegp/common-node). We'll blog about it at https://starthq.com/blog/ https://starthq.com/blog/ in the near future.
- mraleph 12y agoThat actually can be easily fixed on top of V8 - as V8 already sprinkles stack overflow checks you can make actual fiber stack smaller and expand it on demand.
- tjholowaychuk 12y agoawesome!
- olegp 12y agoWe might give this a shot with alexlamsl in a fork of fibers. Would you be able to help if we get stuck?