|
@Bogdan Marinescu – _javascript_ was originally (and still is of course) a browser embedded language designed from the start to be event-driven (if indeed it was ever consciously designed!). Node.JS is a much more recent development that leverages this legacy as an event-driven server language. Of course, other languages can be used in the same way, but it will be more of a force-fit since they were not originally designed to be event-driven. However Lua’s coroutines suggest a further evolution of the event-driven model. Rather than running functions in response to events, we could resume coroutines on events. This would avoid some of the problems with maintaining context in Node.JS. For example you could have a coroutine to respond to an input stream which could execute “yield until more data arrives” and the buffering could all be implemented in local variables. Similarly, “yield for x milliseconds” would be a useful construct to have available in a real-time system.