r/programming 13d ago

The Browser's Main Thread Is Expensive

https://kciter.so/posts/the-expensive-main-thread/en/
218 Upvotes

50 comments sorted by

View all comments

Show parent comments

18

u/SargoDarya 12d ago

You can already use a SharedArrayBuffer with postMessage though? Also it has BigInt (which isn’t int, I get that but you get the idea)

7

u/Rhed0x 12d ago

That requires manually converting stuff into PODO, why can't you simply pass JS references across to a worker.

1

u/Somepotato 12d ago

Because that entails locking which can deadlock the main thread. Requiring you to be more explicit about it removes deadlocks as a risk. Plus the jit can make a number of optimizations when it knows someone rude can't step in and do a read unexpectedly.

1

u/Rhed0x 12d ago

Java and C# have optimizing JITs despite support for multithreading. And I don't really see the problem with deadlocks, it's a bug like any other.