Remix.run Logo
KingOfCoders 2 days ago

I did a lot of Scala Futures and liked the concept, more than 'async' everywhere, because it was easier to reason what happens and functions were just functions. Since some years I use Go where this is even easier.

But it took me some time to realize I can do the same idioms in Go as in Scala:

  // Scala
  f := Future(x)
  // Do something else until you need f
  ...
  for r <- f { ... }
can be written as

  c := channel 
  // Do something else until you need the result
  ...
  r<-c
My mind model was channel as a queue, but it can easily be used like channel as a future for one value.

And `select` for more complicated versions.

I miss the easy composition and delaying of futures though (f.map etc.)