lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



[snip]

@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.


Based on my (admitedly limited) experience with asynchronous event-based systems, the main things that help a lot when using such a system is closure support in your language. Both _javascript_ and Lua can handle that very well (https://luvit.io/ is a good example of that). I really hope I'll have time to experiment with that concept on bare metal in the future. Coroutines in the context of event-based systems are definitely worth a second look :)

Best,
Bogdan