Re:Functional languages will rule (but not this year)
by anonymoushn on Saturday May 28, 2011 @06:39AM
(#2594255)
In Lua, unlike in JavaScript, you don't need to use closures for async programming most of the time.
[ Parent
| on HN ]
Re:Functional languages will rule (but not this year)
by davidhollander on Saturday May 28, 2011 @05:04PM
(#2595214)
Coroutines aren't as flexible as continuation passing style and add significant overhead for the non-vital syntactic sugar they give you.
I'd much rather explicitly set an OnWrite event that has a one-to-one correspondence to a socket write event from a poll() system call, than create a ton of coroutines and juggle "resumes". This is especially true if you have a usecase where you want to start sending while you are still reading, this would require the creation of 2 coroutines per each context.
While Lua coroutines are significantly better than Python generators by having a more functional than syntactical "yield", I still feel it does more harm than good for structuring asynchronous applications.
Re:Functional languages will rule (but not this year)
by silentbicycle on Saturday May 28, 2011 @07:49PM
(#2595478)
Coroutines are less expressive than manually doing CPS, true, but they do make many common cases simpler. They're ultimately as expressive as one-shot continuations.