News for hackers. Stuff that matters.
Re:PHP is worth learning and using by resonious on Thursday November 18, 2021 @07:20AM (#29264593)
Forgive me for going a little off topic here but is it really true that JS was async-friendly from day 1? When I started using JS seriously 8 years ago, async code was horrible (callback hell, etc.) The web standards guys retrofitted native async way after the matter.
Re:PHP is worth learning and using by kall on Thursday November 18, 2021 @08:09AM (#29264970)
Doesn‘t this more or less mean "the only execution environment is event based, has a run loop outside of your control and calls your code whenever it wants" and "there is no busy sleep". So it was callback based from day one. Is that the same as async? I think it is?
Re:PHP is worth learning and using by resonious on Thursday November 18, 2021 @10:50AM (#29266790)
That makes sense, thanks! It has indeed been run in a loop from the start despite the poor ergonomics - I did not think of it in that light.
Re:PHP is worth learning and using by tylergetsay on Thursday November 18, 2021 @07:44AM (#29264768)
async/await is just syntax sugar around promises which are a just a nice way of organizing callbacks, so yes I'd say it's true.
Re:PHP is worth learning and using by nkozyra on Thursday November 18, 2021 @07:45AM (#29264779)
Probably more accurate to say it was async from day one. Which people probably realized the first time they had to deal with setTimeout

The original promises syntax and chaining in ES6 were not particularly user friendly.