News for hackers. Stuff that matters.
Re:I avoid async/await in JavaScript by kccqzy on Tuesday August 13, 2024 @08:10PM (#41241212)
I agree. People should gradually build up their intuition from lower abstractions to higher. People should be banned from using async/await unless they had first experienced callback-based code, and then promise-based code. Going straight to async code is like asking people to run before they have learned to walk.
Re:I avoid async/await in JavaScript by rileymat2 on Tuesday August 13, 2024 @10:20PM (#41241949)
It is not clear to me where you stop the tunneling down the abstractions. It seems arbitrary to each person to their knowledge base.

I have a degree in Electrical Engineering, and don't understand how programmers can function not understanding physical computer architecture.

But clearly, that's not the bar which most come from.

Re:I avoid async/await in JavaScript by THBC on Wednesday August 14, 2024 @12:38AM (#41242592)
What? In JS async/await is _literally_ syntactic sugar for returning/thening promises.
Re:I avoid async/await in JavaScript by kccqzy on Wednesday August 14, 2024 @08:26AM (#41245281)
They need to have experience and intuition working with promises without syntactic sugar, before being allowed to use syntactic sugar.

It's a basic way to learn. In Python you don't directly teach people about decorators without first asking them to explicitly reassign a function to the result of calling the decorator. In Haskell you don't teach people about do notation without first making them write nomadic code with the bind operator and many lambdas.

In many cases, just a few days of forbidding students to use the syntactic sugar is enough to make them appreciate why this syntactic sugar is needed and how it is supposed to be used. JavaScript's async/await is the same.