4 ms·
I believe we, developers, would love to see benchmarks or a few small code snippets rather than pure documentation. By the way, I have noticed that Ryan Dahl o
by alpb 15y ago
I believe we, developers, would love to see benchmarks or a few small code snippets rather than pure documentation. By the way, I have noticed that Ryan Dahl of node.js has mentioned you on twitter @ryah:
> Cute but only a fool would introduce this complexity and overhead for easing their C programming experience.
Anyway, that's cool. Keep up good work, tebrikler :)
- halayli 15y agoI do have few small code snippets + examples in the docs. https://github.com/halayli/lthread/tree/master/src/examples https://github.com/halayli/lthread/tree/master/src/examples thanks for the heads up. :)
- vvnraman 15y agoI would like to know something here. Since there is only 1 stack for a pThread and the stack state is swapped on a context switch for a co-routine within a pThread, wouldn't this be quite expensive if there are a lot of variables on stack for that co-routine? Or is the swapping being carried out in a different manner, eg. caching, pre-allocated stacks, etc..
- halayli 15y agoIf you don't have large variables allocated on the stack, the copy is quite fast. This is easily avoidable by allocating on the heap.
- zedshaw 15y agoRyan has a vested interest in not having people adopt coroutines since they show that his stupid "events with callbacks are faster and easier than threads" is bullshit. The truth is if you have coroutines (and these are really easy in unix with C), then you don't need callbacks and you can make an event based system look and work exactly like a thread based system without the shared resource drawbacks. With coroutines you can also do callbacks, so you can get the best of all worlds, which you can't get with pure callbacks only system like Node.js has.
- shirro 15y agoWell to be fair Javascript is kind of limited so Ryan does not have language support for coroutines unless he wants to redesign Javascript. Even better for node.js would be something a bit more CSP-like such as goroutines and channels but again - Javascript. If you want Javascript with coroutines you can always use Lua.
- someone13 15y agoAnd heck, there's even a Node.js-ish library for Lua: https://github.com/luvit/luvit https://github.com/luvit/luvit
- politician 15y agoTangent: Does anyone know if Node.js on NaCl is possible? exists?
- wmf 15y agoI must be missing something; if you're in the browser you already have JavaScript.
- LeafStorm 15y agoSpeaking of Lua, it doesn't actually have any language constructs for coroutines - coroutine creation and switching is handled entirely via library functions in the `coroutine` package. So while adding coroutine support to V8 would probably require some substantial internal rewrites, it wouldn't necessitate changing the language - just add a global Coroutine object with the coroutine-switching functions like create, resume, yield...
- silentbicycle 15y agoRight, it just needs a sufficiently powerful C API and internals designed with coroutines in mind. ("just" sounds out of place, there...) If you want to look at the Lua coroutine implementation, start at auxresume (http://www.lua.org/source/5.1/lbaselib.c.html#auxresume http://www.lua.org/source/5.1/lbaselib.c.html#auxresume) in lbaselib.c, and the functions tagged luaB_ more generally. (In 5.2, they've been moved to their own file, lcorolib.c.)