Hacker News new | ask | show | jobs
by 29athrowaway 962 days ago
It is not what is widely understood as concurrency and the documentation for Promise type is clear in that regard.

Nothing happens concurrently (at the same time), only asynchronously (at different times).

From the documentation:

> Note that JavaScript is single-threaded by nature, so at a given instant, only one task will be executing, although control can shift between different promises, making execution of the promises appear concurrent. Parallel execution in JavaScript can only be achieved through worker threads.

I hope that explains it for you.

1 comments

Concurrency != Parallel execution
In JS, without worker threads or similar situations, you don't have real race conditions. Therefore, concurrency primitives like mutexes, read/write locks, condition variables, barriers, semaphores, etc. are not necessary. Or Go-like channels.

You can use a global variable and it will be fine because it won't be accessed simultaneously.

So then how is this not cargo culting Go? imitating the observable parts of Go without truly understanding what it does?

What makes data races not a "real race condition"?

Anyhow, do what you will. I don't get the impression that you are genuinely interested in this topic.

Thanks for conceding the point. Have fun.