Foreword
The book you’re holding now is a fun one. It’s a JavaScript book that opens with examples written in C, talks about multithreading with an explicitly single-threaded programming language, provides great examples of how and when to intentionally block the event loop after experts have been telling you for years to never do so, and closes with an excellent list of reasons and caveats about why you might not actually want to use the mechanisms the book describes. More importantly, it’s a book that I would consider essential reading for any JavaScript developer no matter where your code is expected to be deployed and run.
When I’ve worked with companies to help them build more efficient and more performant Node.js and JavaScript applications, I’ve often had to step back and take the time first to discuss many of the common misconceptions developers have about the programming language. For instance, I once had an engineer with a long history in Java and .NET development argue that creating a new promise in JavaScript was a lot like creating a new thread in Java (it’s not), and that promises allow JavaScript to run in parallel (they don’t). In a separate conversation someone had created a Node.js application that was spawning over a thousand simultaneous worker threads and wasn’t sure why they weren’t seeing an expected improvement in performance while testing on a machine that had only eight logical CPU cores. The lesson from these conversations is clear: multithreading, concurrency, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access