News for hackers. Stuff that matters.
Re:Show HN: Ts-Chan – Go-Like Concurrency Primitives for Typ... by joeycumines on Monday November 06, 2023 @08:24AM (#38162267)
Yep, JS is still single threaded, and all that.

I agree async iteration is pretty good - the `Chan` class implements both `Iterable` and `AsyncIterable`.

For quite a few scenarios, async generators are a better choice. They do have limitations, however. For example, you _can_ implement fan-in, but there's no easy mechanism to fan-in in a blocking manner, from sources that aren't known ahead of time. It's also hard to implement a "fair" mechanism, that doesn't bias certain inputs (like you might desire if multiplexing logs, for example).

Re:Show HN: Ts-Chan – Go-Like Concurrency Primitives for Typ... by felipellrocha on Monday November 06, 2023 @09:57AM (#38163454)
Couldn’t you spin N workers and assign work to them?
Re:Show HN: Ts-Chan – Go-Like Concurrency Primitives for Typ... by joeycumines on Monday November 06, 2023 @03:44PM (#38168706)
Fan-in is the other way, but yeah you can do batches of concurrent operations in JS fairly easily.

I still like "pipelining" over that, but that can also be implemented with just an iterator, pretty trivially.

Re:Show HN: Ts-Chan – Go-Like Concurrency Primitives for Typ... by kreetx on Tuesday November 07, 2023 @07:10AM (#38175920)
The value proposition of the library became much clearer, thanks for explaining!