2 ms·
Promises do not suck at all. They save us from the callback hell. Never treat JavaScript as if it's C, they have fundamental differences. The biggest differenc
by ckocagil 9y ago
Promises do not suck at all. They save us from the callback hell. Never treat JavaScript as if it's C, they have fundamental differences.
The biggest difference is that JS is designed to run in an event loop inside a single thread. If you perform a 10 second blocking I/O your thread will freeze. You don't want your browser/tab to be unresponsive. Or in the case of a web server you want to accept incoming TCP connections as fast as you can.
You can achieve parallelism with threads but it's very tricky to scale. If you want a simpler, threaded, blocking programming model I suggest you take a look at Go.
Edit: Definitely read the original slides from Ryan Dahl's JSConf 2009 presentation, they perfectly explain the point of using JS: http://tinyclouds.org/jsconf.pdf http://tinyclouds.org/jsconf.pdf