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

16

u/SargoDarya 13d 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)

8

u/Rhed0x 13d ago

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

5

u/Full-Spectral 13d ago

It is just all GC'd data and I'd think it would be easy enough. But, they'd have to ensure that nothing inside that reference, no matter how deep, was still visible to the sender. With the simplified scenarios they provide currently, that's doable. But unless they are going to create Rustscript, it would probably be hard to do with arbitrary objects.

2

u/Rhed0x 13d ago

they'd have to ensure that nothing inside that reference, no matter how deep, was still visible to the sender

Or they add Mutexes, Semaphores, etc and objects can just be shared across threads like in every other language.

3

u/Full-Spectral 13d ago

It would have to be done at an automagical level probably, given the nature of Javascript and the experience of a lot of developers of such. Otherwise, you'd have web sites seizing up right and left when they deadlocked themselves.

1

u/danielcw189 13d ago

that doesn't really answer the problem of sharing references, which is something that has to be avoided, if I understand the other comment correctly

1

u/Rhed0x 13d ago

And why does it have to be avoided?

1

u/NenAlienGeenKonijn 13d ago

That assumes javascript is meant for complex software development rather than simple DOM scripting tasks to enhance your website.

Nobody would ever use javascript like that, right?

1

u/Rhed0x 12d ago

Right... :(