by gwbas1c · 1y ago · 0 comments
No, he's your drunk uncle who sounds smart when you're young. When you learn to form opinions of your own, you realize that his opinions are worthless hot air.
Many years ago I went to a session where he promoted asynchronous Javascript as the "one true way." In the Q&A, I pointed out that callbacks made code much harder to read and maintain compared to threaded code; and then asked if there was a cleaner way to do it.
His answer was quite rude. A few years later, we got the "async" keyword, which solved the problem.
And they don't solve the core issue of async control flow that async/await solves, so it's not an alternative to async/await much less a superior one.
A classic example is when you want to conditionally do something asynchronously like B() in this case.
function process(id, callback) {
A(id, (result) => {
if (result === 3) {
B(() => {
C(result, callback);
});
} else {
C(result, callback);
}
});
}
Versus: async function process(id) {
const result = await A(id);
if (result === 3) {
await B();
}
return C(result);
}
Add a couple more layers of this and the async/await function stays simple and flat, and the callback version grows significantly more complex and nested.No serious person is going to claim that any form of callbacks is superior to async/wait
Note that your question didn't challenge this point (Async javascript is the "one true way", given that blocking in browser context always degrades the user experience).
The way you've bitterly dwelled [0][1] on something Crockford once said about async during a Q&A for 15 years or something is maybe a little bit weird.
There, I've explained myself, and I think the explanation is relatively straightforward. Now you. Why do you obsess bitterly over something Crockford said to you fifteen years ago during a Q&A? Perhaps more importantly, have you discussed Crockford with a therapist?