frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

We deserve a better streams API for JavaScript

https://blog.cloudflare.com/a-better-web-streams-api/
54•nnx•1h ago

Comments

user3939382•59m ago
“ The Streams Standard was developed between 2014 and 2016 with an ambitious goal to provide "APIs for creating, composing, and consuming streams of data that map efficiently to low-level I/O primitives." Before Web streams, the web platform had no standard way to work with streaming data.”

This is what UDP is for. Everything actually has to be async all the way down and since it’s not, we’ll just completely reimplement the OS and network on top of itself and hey maybe when we’re done with that we can do it a third time to have the cloud of clouds.

The entire stack we’re using right down to the hardware is not fit for purpose and we’re burning our talent and money building these ever more brittle towering abstractions.

afavour•54m ago
UDP is a protocol, not an API
delaminator•19m ago
We're too busy building products while waiting for the perfect system to arrive.
kg•47m ago
It's a real shame that BYOB (bring your own buffer) reads are so complex and such a pain in the neck because for large reads they make a huge difference in terms of GC traffic (for allocating temporary buffers) and CPU time (for the copies).

In an ideal world you could just ask the host to stream 100MB of stuff into a byte array or slice of the wasm heap. Alas.

amluto•14m ago
I wonder if you can get most of the benefit BYOB with a much simpler API:

    for await (const chunk of stream) {
        // process the chunk
        stream.returnChunk(chunk);
    }
This would be entirely optional. If you don’t return the chunk and instead let GC free it, you get the normal behavior. If you do return it, then the stream is permitted to return it again later.

(Lately I’ve been thinking that a really nice stream or receive API would return an object with a linear type so that you must consume it. This would make it impossible to write code where task cancellation causes you to lose received data. Sadly, mainstream languages can’t do this directly.)

ai-christianson•36m ago
The point about BYOB reads is spot on. It's frustrating that such a critical feature for performance and reducing GC pressure ended up being so difficult to implement correctly in the WHATWG standard. A simpler, more ergonomic approach to buffer management would go a long way for those of us building high-performance data processing tools in JS.
slowcache•15m ago
> high-performance data processing tools in JS

I may be naive in asking this, but what leads someone to building high perf data tools in JS? JS doesn't seem to me like it would be the tool of choice for such things

dilap•35m ago
> The problems aren't bugs; they're consequences of design decisions that may have made sense a decade ago, but don't align with how JavaScript developers write code today.

> I'm not here to disparage the work that came before — I'm here to start a conversation about what can potentially come next.

Terrible LLM-slop style. Is Mr Snell letting an LLM write the article for him or has he just appropriated the style?

lapcat•30m ago
You’ve got it backwards: LLMs were trained on human writing and appropriated our style.
jitl•20m ago
cloudflare does seem to love ai written everything
shevy-java•35m ago
We deserve a better language than JavaScript.

Sadly it will never happen. WebAssembly failed to keep some of its promises here.

postalrat•17m ago
Where can I find these not kept promises?
nindalf•10m ago
They haven't yet made languages other than JavaScript first-class languages for the web - https://hacks.mozilla.org/2026/02/making-webassembly-a-first.... I wouldn't call this a broken promise, but it was something people were hoping would take less than a decade.
gejose•14m ago
There's always a comment like this in most discussions about javascript.
conartist6•19m ago
As it happens i have an even better API than this article proposes!

The propose just using an async iterator of UInt8Array. I almost like this idea, but it's not quite all the way there.

They propose this:

  type Stream<T> = {
    next(): Promise<{ done, value: UInt8Array<T> }>
  }
I propose this, which I call a stream iterator!

  type Stream<T> = {
    next(): { done, value: T } | Promise<{ done, value: T }>
  }
Obviously I'm gonna be biased, but I'm pretty sure my version is also objectively superior:

- I can easily make mine from theirs

- In theirs the conceptual "stream" is defined by an iterator of iterators, meaning you need a for loop of for loops to step through it. In mine it's just one iterator and it can be consumed with one for loop.

- I'm not limited to having only streams of integers, they are

- My way, if I define a sync transform over a sync input, the whole iteration can be sync making it possible to get and use the result in sync functions. This is huge as otherwise you have to write all the code twice: once with sync iterator and for loops and once with async iterators and for await loops.

- The problem with thrashing Promises when splitting input up into words goes away. With async iterators, creating two words means creating two promises. With stream iterators if you have the data available there's no need for promises at all, you just yield it.

- Stream iterators can help you manage concurrency, which is a huge thing that async iterators cannot do. Async iterators can't do this because if they see a promise they will always wait for it. That's the same as saying "if there is any concurrency, it will always be eliminated."

conartist6•4m ago
There's one more interesting consequence: you rid yourself of the feedback problem.

To see the problem let's create a stream with feedback. Lets say we have an assembly line that produces muffins from ingredients, and the recipe says that every third muffin we produce must be mushed up and used as an ingredient for further muffins. This works OK until someone adds a final stage to the assembly line, which puts muffins in boxes of 12. Now the line gets completely stuck! It can't get a muffin to use on the start of the line because it hasn't made a full box of muffins yet, and it can't make a full box of muffins because it's starved for ingredients after 3.

If we're mandated to clump the items together we're implicitly assuming that there's no feedback, yet there's also no reason that feedback shouldn't be a first-class ability of streams.

murmansk•11m ago
For gods sake, finally, somebody have said this!
ralusek•3m ago
I tinkered with an alternative to stream interfaces:

https://github.com/ralusek/streamie

allows you to do things like

    infiniteRecords
    .map(item => doSomeAsyncThing(item), { concurrency: 5 });
And then because I found that I often want to switch between batching items vs dealing with single items:

    infiniteRecords
    .map(item => doSomeAsyncSingularThing(item), { concurrency: 5 })
    .map(groupOf10 => doSomeBatchThing(groupsOf10), { batchSize: 10 })
    // Can flatten back to single items
    .map(item => backToSingleItem(item), { flatten: true });

Have your cake and decompress it too

https://spiraldb.com/post/cascading-compression-with-btrblocks
1•emschwartz•45s ago•0 comments

Show HN: Music Discovery Marketplace

https://www.secondtrack.co/discover
1•eriatarka•56s ago•0 comments

Tesla China delivery times collapse to 1-3 weeks as it extends financing again

https://electrek.co/2026/02/27/tesla-tsla-china-delivery-times-collapse-extends-financing-demand/
1•breve•1m ago•0 comments

2-3 Cups of Coffee a Day May Reduce Dementia Risk

https://www.nytimes.com/2026/02/09/health/coffee-tea-dementia-risk.html
1•brandonb•1m ago•0 comments

Mixture of Experts (MoEs) in Transformers

https://huggingface.co/blog/moe-transformers
1•ibobev•1m ago•0 comments

Tudumb

https://spyglass.org/netflix-warner-bros-paramount-deal/
1•colinprince•4m ago•0 comments

Mondrian Entered the Public Domain. The Estate Disagrees

https://copyrightlately.com/mondrian-public-domain-controversy/
1•Tomte•4m ago•0 comments

If you drive clock wise along the beach on an island

1•Cookingboy•5m ago•0 comments

Software Quality (and Reliability, and Frugality)

https://morrick.me/archives/10267
1•speckx•7m ago•0 comments

Show HN: Alba – Earn and bid on unique software using idle AI credits

https://alba-run.vercel.app/
1•WadeToEarth•8m ago•0 comments

Show HN: Treekei – understand project code structure in seconds

https://github.com/zihao-liu-qs/treekei
2•zihao-liu-qs•8m ago•1 comments

Apple Magic TouchstreamLP: Using the Apple Magic Trackpad as Keyboard

https://github.com/disarmyouwitha/AppleMagicTouchstreamLP
1•tosh•8m ago•0 comments

NASA shakes up its Artemis program to speed up lunar return

https://arstechnica.com/staff/2026/02/nasa-shakes-up-its-artemis-program-to-speed-up-lunar-return/
2•LorenDB•11m ago•0 comments

Show HN: Gas Town Control Plane – hosted monitoring for multi‑agent workspaces

https://github.com/SmolNero/gastown-control-plane
1•edgar_ortega•13m ago•0 comments

An Ode to Houseplant Programming

https://hannahilea.com/blog/houseplant-programming/
1•evakhoury•14m ago•0 comments

Toxic combinations: when small signals add up to a security incident

https://blog.cloudflare.com/toxic-combinations-security/
1•unknownhad•15m ago•0 comments

Show HN: ClawDocx – We built a skill and guide library for OpenClaw AI agents

https://clawdocx.com/
1•obobobo•16m ago•0 comments

Rivian was saved by software in 2025

https://techcrunch.com/2026/02/12/rivian-was-saved-by-software-in-2025/
1•PaulHoule•17m ago•0 comments

Show HN: Offline-First Agent Multiplexer

https://twitter.com/ethansteininger/status/2027401658272031108
1•Beefin•17m ago•0 comments

Media Diet

https://macwright.com/2026/02/05/media-diet
1•speckx•17m ago•0 comments

Traveling neighborhoods: a different kind of group trip (2024)

https://devon.postach.io/post/traveling-neighborhoods-a-different-kind-of-group-trip
1•surprisetalk•18m ago•0 comments

Colt's Revolutions (2024)

https://taylor.town/colt
1•surprisetalk•19m ago•0 comments

AI RSS feed summarizer that powers feeds.carmo.io

https://github.com/rcarmo/feed-summarizer
1•janandonly•19m ago•0 comments

Why Concepts Aren't Objects

https://essenceofsoftware.com/posts/concepts-and-oop/
1•surprisetalk•19m ago•0 comments

Show HN: Badge that shows how well your codebase fits in an LLM's context window

https://github.com/qwibitai/nanoclaw/tree/main/repo-tokens
8•jimminyx•19m ago•2 comments

The Simple Essence of Monomorphization [video]

https://www.youtube.com/watch?v=xqoTzQ9b9S0
1•surprisetalk•19m ago•0 comments

Ente Locker

https://ente.io/blog/locker/
2•pentagrama•19m ago•0 comments

Most Knowledge Management Systems Fail

https://desktopcommander.app/blog/ai-knowledge-management-system/
1•rafaepta•19m ago•0 comments

Show HN: BotBrowser – MCP server, saves 90% of tokens for web-browsing agents

https://www.thebotbrowser.com/
1•amplifyco•20m ago•1 comments

Snyk Agent Scan: Security scanner for AI agents, MCP servers and agent skills

https://github.com/snyk/agent-scan
1•lbeurerkellner•21m ago•0 comments