JavaScript Concurrency

Build better software with concurrent JavaScript programming, and unlock a more efficient and forward thinking approach to web development

JavaScript Concurrency

This ebook is included in a Mapt subscription
Adam Boduch

1 customer reviews
Build better software with concurrent JavaScript programming, and unlock a more efficient and forward thinking approach to web development
$10.00
$44.99
RRP $35.99
RRP $44.99
eBook
Print + eBook
Access every Packt eBook & Video for just $100
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Find Out More
 
Preview in Mapt

Book Details

ISBN 139781785889233
Paperback292 pages

Book Description

Concurrent programming may sound abstract and complex, but it helps to deliver a better user experience. With single threaded JavaScript, applications lack dynamism. This means that when JavaScript code is running, nothing else can happen. The DOM can’t update, which means the UI freezes. In a world where users expect speed and responsiveness – in all senses of the word – this is something no developer can afford.

Fortunately, JavaScript has evolved to adopt concurrent capabilities – one of the reasons why it is still at the forefront of modern web development. This book helps you dive into concurrent JavaScript, and demonstrates how to apply its core principles and key techniques and tools to a range of complex development challenges. Built around the three core principles of concurrency – parallelism, synchronization, and conservation – you’ll learn everything you need to unlock a more efficient and dynamic JavaScript, to lay the foundations of even better user experiences.

Throughout the book you’ll learn how to put these principles into action by using a range of development approaches. Covering everything from JavaScript promises, web workers, generators and functional programming techniques, everything you learn will have a real impact on the performance of your applications. You’ll also learn how to move between client and server, for a more frictionless and fully realized approach to development. With further guidance on concurrent programming with Node.js, JavaScript Concurrency is committed to making you a better web developer.

The best developers know that great design is about more than the UI – with concurrency, you can be confident every your project will be expertly designed to guarantee its dynamism and power.

Table of Contents

Chapter 1: Why JavaScript Concurrency?
Synchronous JavaScript
Types of concurrency
JavaScript concurrency principles: Parallelize, Synchronize, Conserve
Summary
Chapter 2: The JavaScript Execution Model
Everything is a task
Execution contexts
Creating tasks using timers
Responding to DOM events
Responding to network events
Concurrency challenges with this model
Summary
Chapter 3: Synchronizing with Promises
Promise terminology
Resolving and rejecting promises
Reacting to promises
Building callback chains
Synchronizing several promises
Promises without executors
Summary
Chapter 4: Lazy Evaluation with Generators
Call stacks and memory allocation
Creating generators and yielding values
Infinite sequences
Deferring to other generators
Passing data to generators
Coroutines
Summary
Chapter 5: Working with Workers
What are workers?
Types of workers
Worker environments
Communicating with workers
Sharing application state
Performing sub-tasks with sub-workers
Error handling in web workers
Summary
Chapter 6: Practical Parallelism
Functional programming
Do we need to go parallel?
Candidate problems
Keeping the DOM responsive
Summary
Chapter 7: Abstracting Concurrency
Writing concurrent code
Worker communication with promises
Lazy workers
Using Parallel.js
Worker pools
Summary
Chapter 8: Evented IO with NodeJS
Single threaded IO
More connections, more problems
Evented network IO
Evented file IO
Summary
Chapter 9: Advanced NodeJS Concurrency
Coroutines with Co
Child Processes
Process Clusters
Server clusters
Summary
Chapter 10: Building a Concurrent Application
Getting started
Requirements
Building the API
Building the UI
Additions and improvements
Summary

What You Will Learn

  • Understand exactly how JavaScript works in a web browser environment, and how these mechanisms power our event-driven JavaScript code
  • Use promises to turn complex synchronization scenarios into readable and maintainable values
  • Compute values lazily and avoid unnecessary memory allocations using generators.
  • Write concurrent code that doesn’t feel like concurrent code by abstracting away boilerplate chores
  • Leverage true hardware parallelism with web workers to get a better performance
  • Get to grips with the NodeJS model of concurrency and learn why it’s good for I/O-intensive web applications

Authors

Table of Contents

Chapter 1: Why JavaScript Concurrency?
Synchronous JavaScript
Types of concurrency
JavaScript concurrency principles: Parallelize, Synchronize, Conserve
Summary
Chapter 2: The JavaScript Execution Model
Everything is a task
Execution contexts
Creating tasks using timers
Responding to DOM events
Responding to network events
Concurrency challenges with this model
Summary
Chapter 3: Synchronizing with Promises
Promise terminology
Resolving and rejecting promises
Reacting to promises
Building callback chains
Synchronizing several promises
Promises without executors
Summary
Chapter 4: Lazy Evaluation with Generators
Call stacks and memory allocation
Creating generators and yielding values
Infinite sequences
Deferring to other generators
Passing data to generators
Coroutines
Summary
Chapter 5: Working with Workers
What are workers?
Types of workers
Worker environments
Communicating with workers
Sharing application state
Performing sub-tasks with sub-workers
Error handling in web workers
Summary
Chapter 6: Practical Parallelism
Functional programming
Do we need to go parallel?
Candidate problems
Keeping the DOM responsive
Summary
Chapter 7: Abstracting Concurrency
Writing concurrent code
Worker communication with promises
Lazy workers
Using Parallel.js
Worker pools
Summary
Chapter 8: Evented IO with NodeJS
Single threaded IO
More connections, more problems
Evented network IO
Evented file IO
Summary
Chapter 9: Advanced NodeJS Concurrency
Coroutines with Co
Child Processes
Process Clusters
Server clusters
Summary
Chapter 10: Building a Concurrent Application
Getting started
Requirements
Building the API
Building the UI
Additions and improvements
Summary

Book Details

ISBN 139781785889233
Paperback292 pages
Read More
From 1 reviews

Read More Reviews