frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Async Mutexes

https://matklad.github.io/2025/11/04/on-async-mutexes.html
17•ingve•1w ago

Comments

pwnna•1h ago
For single-threaded, cooperative multitasking systems (such as JavaScript and what OP is discussing), async mutexes[1] IMO are a strong anti pattern and red flag in the code. For this kind of code, every time you execute code it's always "atomic" until you call an await and effectively yield to the event loop. Programming this properly simply requires making sure the state variables are consistent before yielding. You can also reconstruct the state at the beginning of your block, knowing that nothing else can interrupt your code. Both of these approaches are documented in the OP.

Throwing an async mutex to fix the lack of atomicity before yielding is basically telling me that "i don't know when I'm calling await in this code so might as well give up". In my experience this is strongly correlated with the original designer not knowing what they are doing, especially in languages like JavaScript. Even if they did understand the problem, this can introduce difficult-to-debug bugs and deadlocks that would otherwise not appear. You also introduce an event queue scheduling delay which can be substantial depending on how often you're locking and unlocking.

IMO this stuff is best avoided and you should just write your cooperative multi-tasking code properly, but this is does require a bit more advanced knowledge (not that advanced, but maybe for the JS community). I wish TypeScript would help people out here but it doesn't. Calling an async function (or even normal functions) does not invalidate type narrowing done on escaped variables probably for usability reasons, but is actually the wrong thing to do.

[1]: https://www.npmjs.com/package/async-mutex

michaelsbradley•1h ago
Also:

Developers should properly learn the difference between push and pull reactivity, and leverage both appropriately.

Many, though not all, problems where an async mutex might be applied can instead be simplified with use of an async queue and the accompanying serialization of reactions (pull reactivity).

didibus•29m ago
I'm not fully able to follow what the article is trying to say.

I got especially confused at the actor part, aren't actors share nothing by design?

It does to say there's only 1 actor, so I guess it has nothing to do with actors? They're talking about GenServer-like behavior within a single actor.

As I write this, I'm figuring out maybe they mean it's like a single actor GenServer sending messages to itself, where each message will update some global state. Even that though, actors don't yield inside callbacks, if you send a message it gets queued to run but won't suspend the currently running callback, so the current method will run to completion and then the next will run.

Erlang actors do single-threaded actors with serialized message processing. If I understand the article, that avoids the issue it brings up completely as you cannot have captured old state that is stale when resuming.

gsf_emergency_4•14m ago
So... wait free?

https://en.wikipedia.org/wiki/Non-blocking_algorithm

I can't recommend Grafana anymore

https://henrikgerdes.me/blog/2025-11-grafana-mess/
66•gpi•1h ago•19 comments

AI World Clocks

https://clocks.brianmoore.com/
851•waxpancake•10h ago•288 comments

SSL Configuration Generator

https://ssl-config.mozilla.org/
112•smartmic•6h ago•36 comments

No Leak, No Problem – Bypassing ASLR with a ROP Chain to Gain RCE

https://modzero.com/en/blog/no-leak-no-problem/
49•todsacerdoti•5h ago•2 comments

Has Google solved two of AI’s oldest problems?

https://generativehistory.substack.com/p/has-google-quietly-solved-two-of
232•scrlk•3d ago•153 comments

HipKittens: Fast and furious AMD kernels

https://hazyresearch.stanford.edu/blog/2025-11-09-hk
107•dataminer•1d ago•35 comments

Over-reliance on English hinders cognitive science

https://www.cell.com/trends/cognitive-sciences/fulltext/S1364-6613(22)00236-4
20•DrierCycle•2h ago•20 comments

'No One Lives Forever' turns 25 and you still can't buy it legitimately

https://www.techdirt.com/2025/11/13/no-one-lives-forever-turns-25-you-still-cant-buy-it-legitimat...
203•speckx•12h ago•107 comments

A race condition in Aurora RDS

https://hightouch.com/blog/uncovering-a-race-condition-in-aurora-rds
203•theanomaly•10h ago•67 comments

Structured outputs on the Claude Developer Platform

https://www.claude.com/blog/structured-outputs-on-the-claude-developer-platform
114•adocomplete•10h ago•56 comments

GEN-0 / Embodied Foundation Models That Scale with Physical Interaction

https://generalistai.com/blog/nov-04-2025-GEN-0
36•jackdoe•1w ago•2 comments

All praise to the lunch ladies

https://bittersoutherner.com/issue-no-12/all-praise-to-the-lunch-ladies
152•gmays•9h ago•76 comments

Hiring the Joker

https://quarter--mile.com/hiring-the-joker
4•surprisetalk•1w ago•1 comments

Async Mutexes

https://matklad.github.io/2025/11/04/on-async-mutexes.html
17•ingve•1w ago•4 comments

Show HN: Tiny Diffusion – A character-level text diffusion model from scratch

https://github.com/nathan-barry/tiny-diffusion
112•nathan-barry•4d ago•13 comments

Winamp clone in Swift for macOS

https://github.com/mgreenwood1001/winamp
200•hyperbole•16h ago•125 comments

Manganese is Lyme disease's double-edge sword

https://news.northwestern.edu/stories/2025/11/manganese-is-lyme-diseases-double-edge-sword
132•gmays•12h ago•76 comments

The disguised return of EU Chat Control

https://reclaimthenet.org/the-disguised-return-of-the-eus-private-message-scanning-plot
564•egorfine•11h ago•235 comments

AI note-taking startup Fireflies was really two guys typing notes by hand

https://www.pcgamer.com/software/ai/usd1-billion-ai-company-co-founder-admits-that-its-usd100-a-m...
56•thomassmith65•3h ago•34 comments

Awk Technical Notes (2023)

https://maximullaris.com/awk_tech_notes.html
118•signa11•1w ago•41 comments

Go's Sweet 16

https://go.dev/blog/16years
125•0xedb•6h ago•72 comments

Mentra (YC W25) Is Hiring: Head of Growth to Make Smart Glasses Mainstream

https://www.ycombinator.com/companies/mentra/jobs/2YbQCRw-make-smart-glasses-mainstream-head-of-g...
1•caydenpiercehax•8h ago

Honda: 2 years of ml vs 1 month of prompting - heres what we learned

https://www.levs.fyi/blog/2-years-of-ml-vs-1-month-of-prompting/
298•Ostatnigrosh•4d ago•103 comments

Scientists reverse kidney damage in mice, hope for humans next

https://www.sciencedaily.com/releases/2025/11/251114094525.htm
11•ashishgupta2209•1h ago•1 comments

Being poor vs. being broke

https://blog.ctms.me/posts/2025-11-14-being-poor-or-being-broke/
429•speckx•12h ago•521 comments

Xqerl – Erlang XQuery 3.1 Processor

https://zadean.github.io/xqerl/
39•smartmic•3d ago•8 comments

Bitchat for Gaza – messaging without internet

https://updates.techforpalestine.org/bitchat-for-gaza-messaging-without-internet/
400•ciconia•11h ago•211 comments

Linear algebra explains why some words are effectively untranslatable

https://aethermug.com/posts/linear-algebra-explains-why-some-words-are-effectively-untranslatable
127•mrcgnc•14h ago•97 comments

Moving Back to a Tiling WM – XMonad

https://wssite.vercel.app/blog/moving-back-to-a-tiling-wm-xmonad
66•weirdsmiley•12h ago•62 comments

Raycore: GPU accelerated and modular ray intersections

https://makie.org/website/blogposts/raycore/
20•simondanisch•4d ago•3 comments