Home / Companies / Cloudflare / Blog / Post Details
Content Deep Dive

We deserve a better streams API for JavaScript

Blog post from Cloudflare

Post Details
Company
Date Published
Author
James M Snell
Word Count
7,973
Language
English
Hacker News Points
-
Summary

Streaming data is crucial for modern applications, but the current Web streams standard, developed by WHATWG, faces criticism for outdated design choices that hinder usability and performance. Initially created without leveraging modern JavaScript features like async iteration, the standard's API introduces complexities such as locking models, BYOB (bring your own buffer) reads, and backpressure management that can lead to inefficiencies and resource management issues. Despite significant adoption across platforms like browsers, Node.js, and Deno, the standard's reliance on promises and complex machinery often results in performance bottlenecks, especially in high-frequency or resource-intensive scenarios. An alternative approach, utilizing JavaScript language primitives and async iterables, demonstrates the potential for significant performance gains by simplifying the API, eliminating unnecessary complexity, and providing explicit control over backpressure and buffering policies. This proposal aims to spark a conversation about reimagining the streaming API to better align with contemporary JavaScript practices, emphasizing simplicity, efficiency, and modern functionality.