Hacker News new | ask | show | jobs
by Thorrez 1764 days ago
Green threading is multithreading right? Isn't Javascript singlethreaded? I would assume adding multithreading would break tons of code that relies on it running singlethreaded.
1 comments

It would break the same as sprinkling "await" all around your codebase. Asynchrony in general is not free - you have to redesign around it regardless, and deal with the issues it introduces.
Callbacks have been in Javascript since the beginning, and await is basically syntactic sugar for that.

Having everything switch to blocking and have to start using mutexes and other multithreading primitives would be a giant change to the language.

Callbacks have been there, but most code wasn't written with that in mind. And you still need some synchronization in async code - even if it's all scheduled on a single thread - due to re-entrancy issues.