techhub.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A hub primarily for passionate technologists, but everyone is welcome

Administered by:

Server stats:

4.7K
active users

The term “syntactic sugar” is tricky. Common definition: shorter syntax with a simple transformation to a longer version. Think syntax-aware search-and-replace or macros.

Examples:

a += b // sugar
a = a + b // long

{prop} // sugar
{prop: prop} // long

(x) => x + x // sugar
(x) => { return x } // long

With this definition, async/await is not syntactic sugar for Promises: An async function is executed similarly to a generator (pausing, resuming, …). So no simple transformation from .then().

Sergey Shandar

@rauschma I wouldn't argue about scope of a `syntactic sugar` definition. However, an async function and generator can be transformed into `Promise` and `Iterator` implementation. Also, I agree that it's not simple, it's a good exercise to understand how generators and async functions work.