DEV Community

Discussion on: Explain the synchronous, callback, and async-await (promises) approach like I am 10🧒

Collapse
 
idanarye profile image
Idan Arye

The in your allegory, the problem with the callback approach was that once the restaurant had your number, they could send you spam messages. But there is no parallel to that in actual programming - when you register a callback, no one will send spam to it.

Thread Thread
 
pankajtanwarbanna profile image
Pankaj Tanwar

Yeah. My intention here was to show that we have no control over callback. Not saying you will get spam with callback. SPAM MEANS "NO CONTROL OVER CALLBACK"

Thread Thread
 
idanarye profile image
Idan Arye

Is this an actual problem? The callbacks framework is no a potentially malicious agent that just waits for you to give it a callback so it could abuse it. If it wanted to cause damage, it could just use the fact that it is allowed to run code and even perform IOs. I've never seen a framework that does weird stuff with the callback - you can usually trust it to only run the callback once when the promise is ready.