Kevin Gibbons's Avatar

Kevin Gibbons

@bakkot.com

56
Followers
33
Following
27
Posts
01.09.2023
Joined
Posts Following

Latest posts by Kevin Gibbons @bakkot.com

It makes sense, but it's an excessive amount of boilerplate which almost no one actually writes.

And while it is concurrency, it's not _structured_ concurrency because it doesn't wait for task cleanup to finish in case of errors - so control moves past the block while the tasks are still running.

28.02.2026 15:52 👍 2 🔁 0 💬 1 📌 0

Thanks, fixed.

28.02.2026 15:50 👍 1 🔁 0 💬 0 📌 0
Preview
Towards structured concurrency Towards Structured Concurrency

Put together a presentation on a possible direction for getting native structured concurrency in JS, taking as a constraint that we already live in a world where cancellation means AbortController. Interested in your thoughts!

docs.google.com/presentation...

28.02.2026 04:06 👍 13 🔁 3 💬 4 📌 0

Yup!

You can also do this for IIFEs (which have a similar restriction to avoid ambiguity with FunctionDeclaration) but there's less reason to care in that case.

23.02.2026 18:52 👍 1 🔁 0 💬 0 📌 0

It's more common when there's more than one property. `({ user, body, message } = getRequest());` is much nicer to read than `const request = getRequest(); user = request.user; body = request.body; message = request.message;`.

That said, yes, I also use destructuring for a single property.

23.02.2026 18:30 👍 0 🔁 0 💬 1 📌 0

Only because no one uses it! If we all started doing this then people would recognize this pattern.

23.02.2026 18:28 👍 1 🔁 0 💬 0 📌 0

My most idiosyncratic JS opinion is that we should all write

`0, { x } = y;`

instead of

`({ x } = y);`

so you don't have to jump to the end of the line to add the parenthesis. If only I could convince tooling to support this... (i.e. get prettier not to add the parentheses back)

23.02.2026 00:18 👍 9 🔁 0 💬 4 📌 0

With this attitude, TS becomes much more pleasurable. You can write the code you were going to write anyway but with types written down instead of in your head, and most of the time TS will validate it or catch real bugs, and in the remaining cases you just tell it the right answer and move on.

28.01.2026 19:54 👍 3 🔁 1 💬 0 📌 0

I really like to emphasize to people that TypeScript is going to be wrong about things sometimes, and you need to embrace that this is OK and that you can and should use `// @ts-expect-error` or `as unknown as Foo` in cases where you know better than the typechecker. It's fine!

28.01.2026 19:52 👍 3 🔁 1 💬 2 📌 0

This is such a quintessential "working on JavaScript [and friends]" bug. Dumb compat hacks for engines no one has touched in a decade? Check. Weird parser inconsistencies? Check. Even a BOM mention!

15.01.2026 19:03 👍 3 🔁 0 💬 0 📌 0

If we go with "visible in else" it's actually pretty hard to get disposal to happen before the else! Try rewriting this without relying on "dispose before else":

if (using resource = getResource(); resource.needsUpdate) {
resource.update();
} else {
await postMessage('no updates required');
}

16.12.2025 06:12 👍 1 🔁 0 💬 0 📌 0

Just because that's how you call always `hasOwnProperty` though, it's not something the attacker could actually control. They could have done `Object.hasOwn` if they only cared to work on modern runtimes, and would not benefit from caching in that case.

09.12.2025 20:18 👍 1 🔁 0 💬 1 📌 0

As a person who says the thing you quoted all the time I am confused about the relevance of this CVE, which does not modify any builtins?

09.12.2025 19:15 👍 0 🔁 0 💬 1 📌 0
Preview
AsyncIterator.race/merge · Issue #15 · tc39/proposal-async-iterator-helpers Wanted to write this down so I don't forget, though it won't be in the first version of this proposal. We should have a helper for merging or racing multiple AsyncIterators. When next is first call...

Agreed! I will probably do this as a followup, but have to get regular async helpers first.

github.com/tc39/proposa...

19.11.2025 02:28 👍 3 🔁 0 💬 0 📌 0

Discworld has good values and was this for me at that age. The Tiffany Aching books especially though he might be turned off by 9yo girl protag.

Some of Doctorow's stuff is more explicitly inculcating those specific values, and is good for 13yos. Little Brother is probably a decent first one.

06.11.2025 17:58 👍 2 🔁 0 💬 0 📌 0

Several people blamed the recent npm incidents on JS's minimal standard library.

I think that's wrong: the affected packages are mostly either already covered by node or could not reasonably be in a standard library.

But! I'm always taking suggestions for new stdlib features.

17.09.2025 23:23 👍 6 🔁 0 💬 1 📌 0
Preview
GitHub - tc39/proposal-esm-phase-imports Contribute to tc39/proposal-esm-phase-imports development by creating an account on GitHub.

Not exactly stalled; there's just a lot of work which needs to be done first. Activity currently is at github.com/tc39/proposa.... I believe the plan is for module declarations to proceed after this proposal, with the declaration evaluating to the ModuleSource object introduced in this proposal.

12.09.2025 23:20 👍 3 🔁 0 💬 0 📌 0

That's because this isn't upsert. Upsert does mutation when the value already exists. This doesn't.

31.07.2025 05:15 👍 3 🔁 0 💬 1 📌 0

Pedantry: you made a quiz about _V8_'s Date parser. Almost none of this is required by spec (although it is allowed), and several of these behave differently in other browsers. Which is even worse!

11.07.2025 21:26 👍 10 🔁 0 💬 0 📌 0

A sync iterator yielding a rejected promise is not an error in the iterator, whereas an async iterators doing so is. So when lifting sync to async, we need to handle rejected promises from the iterator as if the _consumer_ had an error (by calling `.return`).

22.05.2025 20:40 👍 1 🔁 0 💬 0 📌 0

Thanks! Further pedantry: "Note that in for of with sync iterators, .return() is always called after .next() throws" - not so. The bug arises because consumers aren't supposed to call .return if the iterator throws, only if the consumer does.

22.05.2025 20:38 👍 0 🔁 0 💬 1 📌 0

So, a break/return/throw inside the loop causes `.return` to be called, but the iterator being exhausted, or throwing, does not call `.return` to be called.

22.05.2025 16:10 👍 0 🔁 0 💬 1 📌 0

Good post! Nitpick: you say `.return` is called "when the iteration stops (due to a break, due to reaching the end of the iterator, or due to the iterator having thrown)". The latter 2 are wrong. It is called only on _early_ exits from the loop which are not caused by the iterator throwing.

22.05.2025 16:10 👍 0 🔁 0 💬 1 📌 0
using controller = new AbortController.AutoAbort();
let pages = await Promise.all(urls.map(url => fetch(url, { signal: controller.signal }));
// automatically cancels outstanding requests if any request fails

using controller = new AbortController.AutoAbort(); let pages = await Promise.all(urls.map(url => fetch(url, { signal: controller.signal })); // automatically cancels outstanding requests if any request fails

Some of that is because the lack of syntax means we don't clean up things we probably should. For example, with a [hypothetical] disposable AbortController, it would be trivial to clean up outstanding fetch requests when other requests fail. Usually JS devs just don't bother.

05.05.2025 16:37 👍 3 🔁 0 💬 0 📌 0

we have almost finished working through your list

chunking is coming in proposal-iterator-chunking

ranges are making less progress

rest is done

x.com/qntm/status/...

21.03.2025 17:15 👍 0 🔁 0 💬 0 📌 0

Any pointers to which? I've previously been skeptical of adding CBOR because I thought it didn't have wide adoption yet but it's already backing web specs that would be relevant data.

31.12.2024 16:05 👍 0 🔁 0 💬 1 📌 0

Parallelism and concurrency! respectively:

github.com/tc39/proposa...
github.com/tc39/proposa...

less exciting but still exciting (but I'm biased): native base64

github.com/tc39/proposa...

26.11.2024 02:12 👍 4 🔁 0 💬 1 📌 0