Hacker News new | ask | show | jobs
by amelius 4082 days ago
It is kind of nasty to break your code into basic blocks, and tie them using library functions. This will certainly not make things much cleaner!

I was hoping one day Javascript could support "deep" coroutines, so we can keep on programming "sequentially" as we did before while still using asynchronous mechanisms.

Perhaps there exist languages that compile to Javascript, that offer deep coroutines (?)

2 comments

ES7 async/await functions? https://github.com/jaydson/es7-async

Babel already enables them.

pogoscript.org has some nice features to let you use async like it was sync.

  fs = require 'fs'
  mojo = fs.readFile 'mojo.txt' 'utf-8' ^!
  console.log (mojo)
(note that if readFile returned a promise you wouldn't need to use the ^)