News for hackers. Stuff that matters.
Re:JavaScript is Eating the World by ralusek on Thursday August 24, 2017 @01:23PM (#15092076)
For the millionth time: It is not accurate to refer to it as single threaded.

The language is non-blocking, so any asynchronous tasks (DB read/writes, disc I/O, cache, http, etc) will immediately jump to processing the next request the moment it is not doing blocking computation.

Non-blocking:

    [aa][bb][cc][/aa][/cc][/bb][dd][ee][ff][gg][/dd][/ff][/gg][/ee]
Blocking-threaded:

    [aa]------------------------[/aa][ff]----------------------[/ff]

    [bb]------------------------[/bb][gg]----------------------[/gg]
    
    [cc]------------------------[/cc][ee]----------------------[/ee]
    
    [dd]------------------------[/dd]
Depending on how many threads you can get going at once, you may be able to achieve comparable performance doing threading, but nonblocking is basically leaving 0 time on the core wasted and limited to the speed of the event loop.

And then on top of that, clustering module is used to do the same thing on every core.

Re:JavaScript is Eating the World by thehardsphere on Thursday August 24, 2017 @02:35PM (#15092745)
It is accurate to refer to it as single threaded, because it executes with a single thread. "Non-blocking" is an orthogonal concept to the number of threads being used.

You can have "non-blocking" and multiple threads at the same time.

Re:JavaScript is Eating the World by pier25 on Thursday August 24, 2017 @03:22PM (#15093174)
Isn't it actually 2 threads at the minimum?

The V8/JS thread and the C++ thread?

Doesn't the C++ part create threads in some cases when needed?

Re:JavaScript is Eating the World by thehardsphere on Thursday August 24, 2017 @06:22PM (#15094572)
I doubt that is accurate, but if it is, it is irrelevant; those "C++ threads" are not available to you to use in your program the way you see fit.