HeadlinesBriefing favicon HeadlinesBriefing.com

Rethinking JavaScript Streams: A Faster Alternative to Web Streams

Hacker News •
×

A JavaScript developer has proposed a new streams API that could be up to 120x faster than the current WHATWG Streams Standard. James M Snell, who helped implement Web streams in Node.js and Cloudflare Workers, argues the existing API has fundamental usability and performance issues that can't be fixed with incremental changes.

Web streams, designed between 2014 and 2016, became the foundation for streaming data across browsers and servers. But Snell points out they were created before JavaScript had async iteration, forcing developers to use complex reader/writer acquisition models instead of the more intuitive `for await...of` syntax. The current API requires excessive ceremony for common operations like reading streams to completion, with manual lock management and error-prone patterns that often break functionality.

Snell's alternative leverages modern JavaScript language primitives and demonstrates significantly better performance across all major runtimes including Node.js, Deno, Bun, and every major browser. The improvements come from fundamentally different design choices rather than clever optimizations. His proposal aims to start a conversation about what could come next for JavaScript streaming, acknowledging the groundbreaking work that came before while suggesting better approaches are possible for today's development landscape.