Day 2 -

June 6th

Track 2 (Waterlink Atrium)

15:15 - 16:00

Async/Await for the Monadic Programmer

I was recently was on a project–not in Scala!–which used async/await for asynchronous computations. Async/await is ““syntactic feature of many programming languages that allows an asynchronous, non-blocking function to be structured in a way similar to an ordinary synchronous function.”” (Wikipedia) Using it was very confusing to me as I had first learned async programming with Futures. I have to use some magic keywords when dealing with async code? Why would anyone want to do this, instead of using a monad like Future? (Monad just means you can flatMap() it or use it in a for-comprehension.)

It took me a couple of weeks to become comfortable, but I started to understand the rationale of async/await and would like to share it with you, so you don’t have to be as confused as I was–or at least for as long. You’ll learn:

  • the underlying problem both solutions attempt to solve;
  • how async/await works; and
  • why async/await is a compelling technique.

Many modern languages use async/await, such as Rust and Javascript. Even though Scala doesn’t natively support async/await yet–it’s being discussed, and there are compiler plugins and libraries that offer support for it–learning the technique will improve your understanding of asynchronous programming and allow you to better understand other codebases… as you are porting that code to Scala!.

Adam Rosien

Inner Product LLC

Adam Rosien is a Principal at Inner Product, focused on building systems using functional programming. He previously helped various startups in many domains develop back-end systems and implement continuous deployment practices, and also spent five years as a developer at Xerox PARC.

Subscribe

Join our conference

Subscribe and follow @ScalaDays on Twitter for the latest conference updates.