Post

Why the opposite? I first tried Porffor’s model in plain JS on Web Workers. Workers can’t share V8 objects, so an object had to move into shared memory as soon as a second thread could see it. It worked, but reading a shared object got ~17x slower.

So now every value is one of three kinds: • owned by one thread, and it moves • deeply immutable, copied once per reader • a struct or SharedArray, laid out in shared memory Ordinary code is plain JS. On 8 threads, Mandelbrot runs 7.6x faster than single-threaded JS, and N-body 4x.

A checker on TypeScript 7 proves the rules: no use after a move, no mutable object reaching two threads. A Vite plugin compiles shared structs down to typed-array reads and writes.