W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2014

RE: Blocking message passing for Workers

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Tue, 12 Aug 2014 17:44:35 +0000
To: Brendan Eich <brendan@secure.meer.net>, David Bruant <bruant.d@gmail.com>
CC: Brian Kardell <bkardell@gmail.com>, Glenn Maynard <glenn@zewt.org>, "adelespinasse@gmail.com" <adelespinasse@gmail.com>, public-webapps WG <public-webapps@w3.org>
Message-ID: <1407865483279.40761@domenicdenicola.com>
One thing that I haven't seen anyone explicitly state on this thread, in response to David's points, is that the semantics are observably and crucially different between

    fs.readFileSync("file.txt");
    console.log("read it!");

and

    await fs.readFile("file.txt");
    console.log("read it!");

The former blocks the event loop, whereas the latter lets it continue spinning. Even though in both cases "read it!" will only be logged after the file is completely read from disk, in the former case *nothing* else will happen (on that thread) until the file is finished reading. Whereas in the latter case, other asynchronous processes may finish and run their continuations; timers may fire; network events may trigger reactions; etc. That can modify local state, complicating your program's reasoning process and certainly making porting hard, if nothing else.

Realizing the difference between these is important background to realizing why async + sugar cannot replace synchronous code. (Apologies if this was stating the obvious...)
Received on Tuesday, 12 August 2014 17:45:26 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:26 UTC