News for hackers. Stuff that matters.
Re:How JavaScript works: Event loop and the rise of Async pr... by amelius on Saturday October 14, 2017 @08:25PM (#15475113)
Yes, but that's a big "if".

Sometimes you want to use a thread to keep the CPU from blocking (e.g. long database operations).

Also, sometimes you want to use the CPU to its full capabilities.

Re:How JavaScript works: Event loop and the rise of Async pr... by fauigerzigerk on Sunday October 15, 2017 @04:58AM (#15476435)
>Sometimes you want to use a thread to keep the CPU from blocking (e.g. long database operations).

On the contrary. That's the prototypical use case for non-blocking event based IO. No threads needed.

>Also, sometimes you want to use the CPU to its full capabilities.

You can use all CPUs by using multiple processes. That's not an issue.

Threads are useful when you want to run multiple algorithms in parallel on the same bigish in-memory data structure, especially one that has a lot of pointers.

Something like an in-memory graph database or a desktop application that lets you work with huge files in-memory, or even complex user interfaces. For instance, I'm not convinced that the cross process bridging that React Native has to do is a great idea.

So yes there are use cases where threads are very beneficial. But on the server side it's essentially the database/analytics systems themselves, not the code that accesses them.

Re:How JavaScript works: Event loop and the rise of Async pr... by frutiger on Saturday October 14, 2017 @11:55PM (#15475809)
Database access, likely the most common I/O operation from a web server, is certainly running in another process (or on another machine) - I'm not sure that "if" is as big as you suggest.