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...)

Reply via email to