Asynchronous Programming - Reading Assignment

  1. Synchronous functions block code from running until finished with the current block. Asynchronous functions don’t block other tasks from completing while waiting for callbacks.

2.- A callback hell is a chain of nested callbacks. A callback is a action the code is awaiting to execute once you get a response from another action.

  1. By using the Promise Library.
1 Like
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous functions are executed in order, waiting on previous statements to be completed before executing the next line of code in the sequence. Asynchronous functions continuously run and don’t have to wait.

  2. What is callback hell?
    Deeply nested structures; unmanageable levels of nested functions in asynchronous programs

  3. Which technique can help us solve callback hell?
    Converting callbacks to promises which helps to gain control over results of callbacks and deal with errors

1 Like

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

synchronous functions can only be executed one by one, the first execution needs to finish before we can continue with the next.

asynchronous functions do not need to wait for the previous execution to finish, all the executions run simultaneously.

2. What is callback hell?

It is when we call functions within functions repeatedly which can make the code hard and complicated to read.

3. Which technique can help us solve callback hell?

By using promises and Jquery’s built-in asynchronous functions we can make the code much easier to read. With this, we can link callbacks and also take care of errors.

1 Like
  1. A synchronous task will be handled until its completion. An asynchronous task can be initiated and then put aside until a later date while the next task gets started.

  2. Callback hell refers to the situation where callbacks are nested within other callbacks several levels deep, potentially making it difficult to understand and maintain the code.

  3. In the browser, a common pattern to deal with excessive callbacks is to use promises. jQuery ships with a simple built-in promise library that enables us to chain callbacks and deal with errors.

1 Like

Seems the link is broken. It’s missing from the course lesson and the link under the forum topic cannot be reached.

Could you explain more ? Which link is broken? We will look into asap.

A. Malik

  1. What is the difference between synchronous and asynchronous functions?
    Synchronous functions are executed in sequence, where each task begins once the previous one has finished. On the other hand asynchronous functions can be initiated and then put aside until a result is available to be operated on, this means that other tasks can continue whilst waiting for the result.

  2. What is callback hell? Callback hell occurs when you have an excessive number of callbacks nested within one another, making the code overly complex to manage.

  3. Which technique can help us solve callback hell?
    Promise is used to solve the call back hell situation. jQuery, AngularJS come with promise library. It also handles errors.

1 Like

Hello,

I also can’t find any link attached on the course page.

1 Like

Which section and which course? Please be more specific so that we can solve the issue.

Thanks. :slight_smile:

Please see the attached screenshots. One is the lesson that is missing the link to the article. The other is the forum topic showing the broken link to the article.
Screenshot_20210621-121522_Brave Screenshot_20210621-121601_Brave

Where is the article? It seems missing in the new version of Academy 2.0??

Please fix as we want to get to blockchain programming as soon as possible!

1 What is the difference between synchronous and asynchronous functions?

synchronous functions execute one after the other.
asynchronous functions can execute while other functions are still running and waiting for callbacks.

  1. What is callback hell?

when there a re multiple functions within functions within functions all waiting for a callback leading to an unstable program.

  1. Which technique can help us solve callback hell?

YOu can use promises on the browser side and Fibre on the server side.

Alright got it. WE will fix this as soon as possible. Will notify you once done. Thank you for pointing out.

Have a nice day. :slight_smile:

@BigBossCryptoChain @DavidV @morganw

The issue is resolved. Please check the course section.

Happy learning! :slight_smile:

2 Likes
  1. When synchronous functions are called, the compiler may only execute that one single function at a time. If the function requires some response, it will wait for the response to proceed with executing the remainder of the JavaScript program. This means the program will sit still doing nothing until a certain requirement is satisfied.
    Oftentimes JavaScript could make some request, and continue rendering the rest of the program. These sorts of functions that allow the JavaScript code to continue executing while it waits for a response from a prior function are called asynchronous.

  2. Callback hell exists when a number of functions in a program are all waiting for response for it to continue with the next action. Callback hell is known as the building up of nested executions which require some response from the parent event to proceed to the nested events.
    Many relatively simple programs can have several nested callbacks. This is known as callback hell.

  3. On the client side, we can use Promises, which is a jQuery library to assist with chaining callbacks and dealing with errors.
    On the server side, we can use a Fibers Package which allows the programmer to code in a synchronous style, while the package takes the code and uses it asynchronously with synchronous control flow.

1 Like

Seems I got lucky with timing here on this one!
Thanks for sorting out :heart:

1 Like
  1. Synchronous functions are functions that can only happen 1 at a time, “blocking” the javascript engine from carrying out other tasks until the function has been executed, whereas asynchronous is the opposite, multiple functions are carried out without blocking the javascript engine, instead, while the program waits for one function to execute it is free of carrying out other tasks in the mean time.

2.Callback Hell refers to numerous callbacks nested within each other up to a point where it becomes practically unmanagable and untidy.

  1. Promises - a simple built-in “promise” library on Jquery helps solve this as well as something called “Meteor”. also, Node.js provides a different approach as well.
1 Like
  1. synchronous functions are single threaded and can only execute one task at a time, while asynchronous functions allow for code to be executed later or after a response from the first execution of code.
  2. Callback hell is the accumulation of complex operations produces more levels and sub levels of nested functions.
  3. The use of promises which used jquery library to chain callbacks and return errors. Or by using Meteor fiber package Future library. This allows code written synchronous to act as asynchronous in node.js
1 Like
  1. Synchronous functions runs only one section of code at any one time while asynchronous functions do not blocks the thread, they wait to complete execution while thread does other tasks.
  2. Callback hell is numerous functions nested within each other what makes code hard to read and maintain.
  3. Callback hell can be solved using promises which is jQuery library that enables us to chain callbacks and deal with errors.
1 Like