Asynchronous Programming - Reading Assignment


#121
  1. What is the difference between synchronous and asynchronous functions?

                  Synchronous functions run continuously until its completion, an *asynchronous* function can be started and then and the other processing can be completed while the first function is running.
    
  2. What is callback hell?

               Callback hell in JavaScript is when nested code is used to delay a function and the code becomes difficult to read or follow.  
    
  3. Which technique can help us solve callback hell?

                    In the browser, through the use of "promises" or browser triggers provided in  jQuery. Or, extending runtime using "Fibers" via Node.js.

#122
  1. What is the difference between synchronous and asynchronous functions?

A sync task involves executing one line of code or command or something like that and putting everything else on the website on hold till that code is executed. Async involves programming it so that allows the code to be paused for the time being and then resumed later on so that one execution sequence doesn’t hold up the entire set of code from running.

  1. What is callback hell?

Callback hell occurs when there are two many subfunctions so that it’s hard to tell what’s supposed to come first and what’s sync and what’s async.

  1. Which technique can help us solve callback hell?

You can either use Jquery library “promises” which are designed to solve callback issues, or if you’re using node.js utilize “fibers” to make the code look sync even when it’s async, even though it’s not. It’s about rewriting the code in a such a way so that it feels sync even it can’t be.


#123
  1. The difference between synchronous and asynchronous functions is, synchronous functions are executed one section of code at a time. Asynchronous functions can initiate one section of code and set it aside to be completed at a later time, and move on to another section of code.
  2. Callback hell is the amount of nested functions/sub levels inside a piece of code. More complex operations produce more levels and sub levels.
  3. One technique that can help us solve callback hell is called Promises. Its a built-in JQuery library that helps us chain callbacks and deal with errors.