5 ms·
Async Ruby is colorless! It's obvious from the examples provided in the post. For example, you can use the method `URI.open` both synchronously and asynchronou
by brunosutic 5y ago
Async Ruby is colorless!
It's obvious from the examples provided in the post. For example, you can use the method `URI.open` both synchronously and asynchronously.
It's something I didn't want to mention in the article because it's a relatively advanced async concept, but yea - Async Ruby is already colorless and it's great.
- gpderetta 5y agoIIRC ruby has first class continuations, so it doesn't have to deal with any async/await nonsense.
- brunosutic 5y agoThat's right - Async Ruby uses fibers (stackful coroutines) as a concurrency primitive. There's a lot to say about this, but the end result is that we get to write simple synchronous code and it can run asynchronously.
- g8oz 5y agoN00b question: would the fibers being introduced in PHP 8.1 enable the same functionality in that language? https://php.watch/versions/8.1/fibers https://php.watch/versions/8.1/fibers
- nixpulvis 5y agoOn a tangential note. > Async Ruby is colorless! I find it deeply irritating that this is how we choose to describe things these days. Rather than talking about modality, or even using a few more words to describe the actual differences in terms of the underlying programing language models. Telling me that Ruby's async is colorless implies that I know about the description of programming models as "colors" of code, which was just some random analogy someone came up with which caught on. Nothing about this has anything to do with color. Even syntax highlighting doesn't really fit. This is akin to particle physicists getting cheeky and calling one of the quantum states "color" when it has nothing to do with wavelength (correct me if I'm wrong). This is an appeal to stop trying to be so cute. Thank you.
- brunosutic 5y agoRed-black tree, a well-known algorithm also uses color references https://en.wikipedia.org/wiki/Red–black_tree https://en.wikipedia.org/wiki/Red–black_tree
- bradgessler 5y agoWhat is “colorless” suppose to mean? This is the first time I’ve seen it used.
- vmarquet 5y agoI think it's a reference to this blog post https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
- auno 5y agoWhich in turn is making a reference to an even older post at https://ansuz.sooke.bc.ca/entry/23 https://ansuz.sooke.bc.ca/entry/23.
- jsnell 5y agoContext: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
- deleted 5y ago[deleted]
- justsomeuser 5y agoIt references the function return type: Colored = Promise<T> Colorless = T In "colorless" async/await, async functions are implicit (no async keyword), and when called, the compiler auto-unwraps the promise, so everything looks like "sync" code but any function stack could "save and resume" at an "async point".
- 5y ago