4 ms·
Yeah, the await syntax is just bizarre. One of the worst eyesores of any languages I've personally encountered. An await macro or function would have sufficed
by cedws 5y ago
Yeah, the await syntax is just bizarre. One of the worst eyesores of any languages I've personally encountered.
An await macro or function would have sufficed but because Rust is still mainly a hipster language with a hipster community, they had to choose a hipster syntax after years of bikeshedding about how to make it absolutely perfect.
- zozbot234 5y agoPrefix syntax has drawbacks that were constantly pointed out in that long discussion. In particular, it doesn't compose well in practical scenarios. .await just 'flows' better and in a more intuituve way.
- Gwypaas 5y agoCompletely agree. I've used it at work now for about a year and the postfix notation flows perfectly with more intricate usages of futures. Especially with the sense that you construct one, then decide when to await it, or await a collection or whatever. Following the rust style of immutable variables and chaining function calls. You can even await the same future multiple times in a select statement keeping it executing a bit further each time until it returns, if you do it by mutable reference. Really quite magic. Now we just need async closures and some nice async style iterators. Something like FuturesOrdered or even FuturesUnordered in an inline iterator style allowing efficient nice composability. Without any of the pitfalls and gotchas those two currently have. I think that might be what throws many people off? The regular style of method chaining and having the cold futures just be a dead piece of memory you can pass around until actually passed to the runtime?
- steveklabnik 5y ago> An await macro or function would have sufficed We tried, and it literally did not suffice.
- c7DJTLrn 5y agoWorks in other languages fine.
- steveklabnik 5y agoDifferent languages have different semantics. The challenges here are related to the ways Rust works specifically, as well as its goals.