https://retrospring.net/@Fleckenstein/a/112214190761593888
what's something you like about a language you dislike? ——— I would say I like the way Promises and the event loop work in JavaScript. For an easy, interpreted language having a built in event loop with native worker threads is a really good choice and easily allows to use multiple I/O libraries at the same time without having to bother with concurrent multi-threading. For example, if I want to do file IO as well as listen for requests from network (for example, to build a simple terminal chat client for a protocol), the libraries can integrate by relying on this language feature. The library for the network protocol could do receiving, sending and (de-)serialization in its own worker threads and forward events as Promises, and the file IO API can do the same. The programmer has full flexibility: Await on a promise, attach a callback to be ran on completion, join promises or select the one that completes first etc. A feature like this is essentially a convenient abstraction around calling the poll() syscall in a loop or whatever thing Windows has in place for that. There are also timeouts, immediates and intervals, and I think it's just generally well designed. This is something I'm desperately missing in Lua - well, there are solutions like that for it, the issue is, those are third party libraries, I wish it was in the language / standard library itself. You can basically often only use one I/O library at a time since everyone brings their own polling mechanism and they don't integrate, leaving busy waiting as the only "solution".