4 ms·
My point exactly. Both of those languages are synchronous by default, async is an option. JS is async only pretty much* * while there are blocking calls in nod
by andrewvc 14y ago
My point exactly. Both of those languages are synchronous by default, async is an option. JS is async only pretty much*
* while there are blocking calls in node, they are by far the exception. It is not multi-paradigm like Java
- zinkem 14y agoI'm not sure I see the distinction you're identifying. If you're ever written code on the iPhone, everything is done via events. All the code you write is responding to an event fired in the runtime. Any synchronous network calls you make will block the UI thread, so asynchronous calls are the right way to access network resources. This same reasoning is why Node.js libraries are primarily async. It's the right thing to do. edit: To expand, the alternative is to fire off threads for each connection so you can write 'synchronous' code... the whole point of nginx and node is so that you don't need the overhead of creating a separate thread for each connection, asynchronous code is the natural result of this decision.