Asynchronous Programming - Reading Assignment

1.Synchronous functions block the program’s further execution until something is done while asynchronous functions do not block the program and wait while the program thread does other task.
2.Callback hell is a situation where several functions are being performed in nested form.
3.Promise is used to solve the call back hell situation.jQuery, AngularJS come with promise library.It also handles errors.

Hi Ivan,

Loving the course - very well explained. Just letting you know that there is a broken link in Asynchronous Programming - Reading Assignment

Asynchronous Programming

Read this article about promises (https://www.discovermeteor.com/blog/understanding-sync-async-javascript-node/).

The link works as http and not https.

Best regards, Seamus.

  1. What is the difference between synchronous and asynchronous functions?
    A synchronous task will occupy JS continuously until its completion, an asynchronous task can be initiated and then put aside until a later date.
  2. What is callback hell?
    Having more and more levels of functions nested in other functions. It becomes difficult to read and maintain the code.
  3. Which technique can help us solve callback hell?
    We can use promises.
  1. What is the difference between synchronous and asynchronous functions?
    Originally when computers were invented, they worked in a linear progress, from step 1, then to step 2, or from line 1 then to line 2. When an error occurred it would stop the entire program’s code from working, this process is known as synchronous process, which most functions use. With the advancement of network infrastructure and computer architecture this process was altered to be able to handle multiple functions at the same time, aka multitasking but has nothing to do with multithreading on a cpu. In an asynchronous function time that plays a role that distinguishes it from synchronous functions. Instead of the main process relying on the return of output from a function the main process is allowed to continue for process while allowing a related function to process autonomously until an output is returned. The main process has the ability to bypass the need to wait for a return through allocating the asynchronous functions to a separate stream, through allocating it’s own cache to the function.

  2. What is callback hell?
    A callback is basically a function that only works after the main function has completed and requests a result from a function that could only run after load. Because programs require multiple functions to only run after the main code has loaded, all these functions which more than likely are not related to one another through logic, get grouped together and require the use of many nested criteria validators to ensure the correct function is called can be very confusing and difficult to work with, much like hell.

  3. Which technique can help us solve callback hell?
    By avoiding nested code with the use of callback promises we are able to have a much cleaner code and manage errors that we might overlook callback hell. The promise is a callback management tool of the nested functions which allow us to pass data from one function to the other, therefor they don’t have to be nested as they will only invoke a function once they have the data that is required to pass on.

  1. Synchronous way: It waits for each operation to complete, after that only it executes the next operation. Asynchronous way: It never waits for each operation to complete, rather it executes all operations in the first only.

  2. Callback hell is when a JavaScript developer when he tries to execute multiple asynchronous operations one after the other.

  3. The use of Promises , which enables chain callbacks & deals with errors.

  1. What is the difference between synchronous and asynchronous functions? Whereas a synchronous task will occupy Javes continuously until its completion, an asynchronous task can be initiated and then put aside until a later date while our valet gets started on the next task on his to-do list.
  2. What is callback hell? Callback hell occurs when an operation requires various levels of nested functions, so more complex operations tend to produce even more levels and sub-levels.
  3. Which technique can help us solve callback hell? In jQuery we can use “promises” which are designed to solve callback issues, and in Node.js we can use utilize “fibers” to make the code look sync even when it’s async.
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous:Sections of code that won’t allow other sections to be ran until that code is ran.
    Asynchronous:Code that can be put aside until a later date while Javes can move to other tasks.

  2. What is callback hell?
    When there are various levels of nested functions in an operation making it more complex producing more levels and sub-levels.

  3. Which technique can help us solve callback hell?
    Promises built into jQuery can help save the problems behind call back hell by chaining nested functions and call backs to it and dealing with errors by itself without Javes.

What is the difference between synchronous and asynchronous functions?
in synchronous functions we have a hierarchy of functions executed one by one. asynchronous functions can be executed simultaneously / perform multitasking.
What is callback hell?
callback function inside of a call funcntion inside of another call back function and so on
Which technique can help us solve callback hell?
promises.

  1. What is the difference between synchronous and asynchronous functions?
    Synchronous code is often read from top to bottom therefore code is executed in that order,this is considered synchronous programming .
    Asynchronous programming is the process in which code is put to the side to be executed at a later time,such as after the synchronous code is executed.

  2. What is callback hell?

Callback Hell, also known as Pyramid of Doom, is an anti-pattern seen in code of programmers who are not wise in the ways of asynchronous programming. … But once your project requirements start to swell, you will quickly find yourself piling layers of nested callbacks. Congrats! Welcome to Callback Hell.

  1. Which technique can help us solve callback hell?

Promises are a technique that call help control readability of indention problem that occurs when callback hell ensues. Promises are wrappers around asynchronous functions. Promises are an alternative to callbacks.

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

Synchronous functions “lock” the browser (or server) until complete; asynchronous functions leverage callbacks so that processing can continue.

  1. What is callback hell?

Multi-levels (nested) of callbacks within a function.

  1. Which technique can help us solve callback hell?

In Javascript, use promises. In node.js, use fibers.

  1. What is the difference between synchronous and asynchronous functions?
    sync will dot he tasks step by step and can’t do two things on the same moment.
    async can do things on the background while other stuff can be done.

  2. What is callback hell?
    More function at a time are running and it becomes messy.

  3. Which technique can help us solve callback hell?
    To use promises

  1. What is the difference between synchronous and asynchronous functions?
    When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes.

  2. What is callback hell?
    when you have all these callbacks, you have to start indenting and indenting and indenting. It becomes hard to keep track of where you’re at…

  3. Which technique can help us solve callback hell?
    . Write comments
    . Split functions into smaller functions
    . Using Promises
    . Using Async/await

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

Synchronous functions take full attention of the program, they are also called as blocking functions, and they will do the task until its completion.

Asynchronous task can be initiated and then put aside until a later date while the program can execute the next task on his to-do list.

  1. What is callback hell?

Complex operations tend to produce many levels and sub-levels of nested code.

  1. Which technique can help us solve callback hell?

By extending the runtime, we can abstract away the asynchronicity and write code that looks sychronous, but still works asynchronize e.g. Fibers package for Node.js or using promises from jQuery which enable us to chain callbacks and deal with errors.

  1. Sync function always executes as whole and program waits for function to finish and return the result, Async executes fast parts, and heavy parts executes in a parts and the main program just check from time to time until the return result of this function appears in the queue, but main programs continue execution.
  2. Because program does not know when async function will get resolved so all dependant functions have to depend on callbacks, and if there are another functions that depend on second layer functions there can be callback hell, where you are not sure what get executed and in which order, and when all required data will be available
  3. Promises helps to resolve callbacks hell. So you can return promise instead of real value, and when it is needed you can check if it is resolved and execute particular code that depends on the value inside promise.
  1. Synchronous functions are single-threaded and can only run one section of code at a time. No other code will run until after the originally initiated coded is completed. Asynchronous functions, however, will initiate their code but postpone its completion until it receives requested data or meets a specified condition that is expected to take some time. While the asynchronous function is postponed, JavaScript can continue running other functions until the asynchronous function’s callback is triggered.

  2. When code grows increasingly complex due to the inclusion of numerous nested functions, each with its own callback set to trigger after the first. This can make finding errors in the code a hellacious task when the functions don’t cooperate accordingly because the functions are so deeply intertwined in each layer.

  3. jQuery includes a promise library that can be used to deal with callbacks in the browser by appropriately chaining them. In Node.js, the asynchronicity can be abstracted away by extending the runtime. This effectively allows the programmer to write asynchronous code using a synchronous style by utilizing synchronous control flow.

Btw, anyone else have trouble accessing the blog post? I kept getting an SSL certificate error message that would NOT go away no matter how much troubleshooting I did. I finally was able to access it by manually searching for the blog post on my phone. Is there something I overlooked that could’ve fixed this, or is the site’s SSL the issue? Here’s the error:

This site can’t provide a secure connection
www.discovermeteor.com sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

It won’t work for me either :confused:

I ended up just reading the article on my phone, and haven’t had the issue anywhere else since. But if you google the error code: ERR_SSL_PROTOCOL_ERROR, you’ll find a lot of troubleshooting steps you can try if you want to fix it.

Thank you, I’ll give that a try!

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

Syncronous functions can only run one at a time and have to wait for the response before it can continue to execute future code. Asynchronous code can make a call and do other tasks as it waits for the reply from a web page or server etc.

  1. What is callback hell?

When you want to make a simple function to do an easy task but you need to use several nested callback functions that can slow down and cause a living hell involving sweat.

  1. Which technique can help us solve callback hell?
    We can use jQuery promises, a simple built-in promise library that enables us to chain callbacks and deal with errors.