Hacker News new | past | comments | ask | show | jobs | submit login

async/await is a special case of monads (expressible with a for-comprehension); it comes out to:

  def asyncFunction(): Future[Blah] = for {
    foo <- someAsynchronousOperation
    bar <- anotherAsynchronousOperation
  } yield bar.baz



I find async/await to be much better for conditional execution, especially with lots of branches. For example, I had a scenario where I tried one async call and if it didn't have the information I needed, I had to make two subsequent async calls to get the information I needed before proceeding with the final call. Monadic composition was a nightmare where async/await was perfectly suited to the task.


For comprehensions are currently tremendously limited vs async/await. They constrain the top-level of your code structure to a tiny subset of the language.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: