Reputation: 195
I have just found about Dart from Google and wanted to know if true parallelism can be obtained using Dart. From what I know my answer would be no because finally it runs just as Javascript(I cannot comment about how it run on the Dart VM) but then why the design decision of introducing async and await keywords? Will this become something like Erlang?
Upvotes: 5
Views: 2917
Reputation: 657781
A Dart application can consist of one or more isolates. Isolates run as threads (other implementations are possible) and run parallel (also on different CPUs). Communication between isolates works with message passing.
Code within a single isolate is single-threaded and there is no parallelism at all. The execution is event-driven. See also https://webdev.dartlang.org/articles/performance/event-loop
async
/await
is just syntactic sugar to make async code look more like sync code, but it doesn't make code running sync.
Upvotes: 9