I just watched the following video: Introduction to Node.js and still don\'t understand how you get the speed benefits.
Mainly, at one point Ryan Dahl (Node.js\' cre
Note! This is an old answer. While it's still true in the rough outline, some details might have changed because of Node's rapid development in the last few years.
It is using threads because:
To fake non-blocking IO, threads are neccessary: do blocking IO in a separate thread. It is an ugly solution and causes much overhead.
It's even worse on the hardware level:
This is just plain stupid and inefficient. But it works at least! We can enjoy Node.js because it hides the ugly and cumbersome details behind an event-driven asynchronous architecture.
Maybe someone will implement O_NONBLOCK for files in the future?...
Edit: I discussed this with a friend and he told me that an alternative to threads is polling with select: specify a timeout of 0 and do IO on the returned file descriptors (now that they are guaranteed not to block).