Asynchronous Programming - Reading Assignment

    1. Javascript’s To Do List is called the event loop. Synchronous functions are single thread and completed in a linear order. No other processes will be started until a function is completed in order. Asynchronous functions support a background thread and allow other functions to run while the browser is waiting for a response from a function. This may be caused by an API, or query of third party data servers. Asynchronous code usually takes the form of Ajax, which is most commonly used through a jQuery wrapper.
    1. Callback Hell is a situation where code has nested functions/ sub levels that require a response from an external source.
    1. Use promises, jQuery has a simple promise library that enables chaining of callbacks and dealing with errors. Extend the runtime using Node.js so the code looks synchronous. Using Meteor> Fibres > Future.
1 Like
  1. Synchronous functions are executed in sequence, one at a time. Each function waits for the previous to execute. Asynchronous functions do not wait on previous functions, the remaining functions in your program will continue to on. This keeps site responsive and reduces wait time for user.

  2. Callback hell is when there is several nested functions or code using callbacks and it becomes hard to follow.

  3. A promise can solve callback hell as it is an object that returns a resolved or rejected value from an asynchronous function.

1 Like
  1. synchronous is when the computer only can stay on one single task and will not be able to do any second task till the first one is done, but asynchronous is when a task initiated and puts aside for when the process will be done and responds comes back, while waiting for the response there are other tasks that will be handled.

  2. When you want to track a user logs you need few levels and sub-levels of operation, so it produces a complex procedure for calling and storing data in the server and thats why (as its been mentioned) its poetically called callback hell.

  3. 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
  1. A synchronous function is code that run’s with the computer’s full attention. The code following the function will be executed only when the function prior is completed. This is the nature of a single-threaded environment. An asynchronous function however is able return a result once that code is ready while the computer moves on with other tasks.

  2. Callback Hell is understood as the complex set/s of operations that can arise when writing extensive pieces of code using callbacks.

  3. The technique of using “promises” in the browser creates a library that keeps track of callbacks. JQuery comes pre-shipped with a promise library that we can use to keep track of our callbacks.

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    synchronous: must finish before moving on to the next function
    asynchronous: can do multiple functions at the same time
  2. What is callback hell?
    When you have many functions embedded within one another that are all waiting for the previous function to be executed
  3. Which technique can help us solve callback hell?
    jQuery promises.
1 Like
  1. Synchronous function means that each function is executed one after another - when one is finished the other starts to execute. With asynchronous functions one function can still be running (for example when a function is requesting data from the server) while the next function starts to execute.

  2. Callback hell is reffered to when dealing with huge numbers of nested functions.

  3. To solve callback hell we can use the jQuery libaries that have in-built PROMISE library.

1 Like

1.) The difference between synchronous and asynchronous functions is the former operates a single-threaded environment where code is executed consecutively and remains running occupying Javascript’s full attention. Where as, the latter is a coding that can be started and set aside until a later day for its completion.
2.)Callback hell is complex operations with many different levels of nested functions with potentially many level and sub-levels.
3.)The common technique that can help solve callback hell is by using promise in the Jquery library.

1 Like
  1. So, synchronous functions are those that block the program’s flow until their execution is finished. On the other hand, asynchronous functions let the javascript engine to execute other tasks, while waiting for certain events to occur.

  2. Callback hell is known for the situation where there are several nested callback functions.

  3. In order to handle and solve this callback hell scenario, a specific library is used, the promises one. This library is included in JQuery and allow us to chain callbacks and deal with errors.

1 Like
  1. Synchronous functions finish one by one. Asynchronous functions can run more than one task at a time, by putting aside a task in order to initiate another.

  2. A callback hell is basically excessive arguments all waiting for one argument to callback another in order to start another.

  3. We can help the callback hell by using a technique called promises. or by extending the runtime, we can abstract away the asynchronicity and write code that looks sychronous.

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous code is executed in sequence – each statement waits for the previous statement to finish before executing. Asynchronous code doesn’t have to wait – the program can continue to run. You do this to keep your site or app responsive, reducing waiting time for the user.
  2. What is callback hell?
    If a relatively simple operation requires three levels of nested functions, more complex operations tend to produce even more levels and sub-levels, which is what is poetically known as callback hell.
  3. Which technique can help us solve callback hell?
    jQuery with a simple built-in promise library that enables us to chain callbacks and deal with errors.
1 Like
  1. In synchronous programming the program takes care of one task from start to finish before starting another task. With asynchronous programming you can start tasks that take some time to be concluded (like querying a server), do other tasks and finish the firs task when it is ready to be finished.\

  2. Callback hell is a term used to decribe cemplex operations that produce many sub-levels of nested functions.

  3. To solve it in the browser we can use promises. They help us chain callbacks and deal with errors. In node.js we can also abstract the asynchronicity away by extending runtime and write the code that looks synchronous.

2 Likes
  1. What is the difference between synchronous and asynchronous functions?
    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. What is callback hell?
    Callback hell is when many asynchronous functions are held up by waiting for other nested functions to finish execution, essentially holding up the whole process.

  3. Which technique can help us solve callback hell?
    We can use “promises” to help us solve callback hell. JQuery ships with a simple built-in promise library that enables us to chain callbacks and deal with errors.

1 Like

1.Sychronous function is executed in sequence each statement waits for the previous statement to finish before executing. Asynchronous function doesn’t have to wait , your program can continue to run and you don’t have to finish executing the current thing in order to move to the next one.
2. CallBack hell it is mostly caused when a programmer tries to write JavaScript in a way where execution happens visually from top to bottom. Callbacks are just the name of a convention for using JavaScript functions, Instead of immediately returning some result like most functions, functions that use callbacks take some time to produce a result. lots of people make this mistake there is the expectation that whatever happens on line 1 will finish before the code on line 2 starts running and so on but this is not how it works if the next line code executed first it doesnt wait for the previous code to finish executing.
3. using Promises.

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

synchronous means handling one code one operation at a time, not moving on to next statement until previous is complete
asynchronous means making a request and continuing to execute further code while waiting on a response from the request

  1. What is callback hell?

callback hell is the increasing excessive complexity of dealing with asynchronous code waiting for requested information

  1. Which technique can help us solve callback hell?

promises

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    synchronous will continually run until its completion as where asynchrounous tasks can be assigned or put aside until a later date.
  2. What is callback hell?
    complex operations cause callbacks on callbacks
  3. Which technique can help us solve callback hell?
    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. But in Node.js, we can use a different approach. By extending the runtime, we can abstract away the
    asynchronicity and write code that looks sychronous.
1 Like
  1. Synchronous functions run code step-by-step and will block further execution of code until task is completed. Asynchronous functions can execute more than one piece of code at the same time.
  2. Callback hell is a place where developers suffer eternal torment for nesting many callback functions while trying to solve some complex operation. Such code is error-prone, hard to read and maintain.
  3. Thanks to jQuery we can use promises to deal with it. In Node.js there is possibility of abstracting away the asynchronicity and writing code that looks synchronous.
1 Like
  1. Synchronous functions are ‘blocking’ functions, meaning control flow is arrested and the browser won’t respond to any other events until it completes the function. Asynchronous functions will be initiated then set aside while control flow continues.
  2. ‘Callback hell’ results from many nested functions having to complete then drop back into flow creating a complex web of functions, known as ‘callback hell’ presumably because it would get complicated quickly and be hard to debug.
  3. ‘Promises’, Meteor with ‘Fibers’ package in Node.js or possibly other libraries can help us with this issue.
1 Like
  1. Synchronous functions occur sequentially. One task must finish before the next task begins. Asynchronous functions can be initiated and then set aside until a later time (allowing other tasks to be completed during this time).
  2. “Callback Hell” is JavaScript code written asynchronously in which one callback is nested into another callback which is nested into another callback…and so on. It produces messy code that is difficult to maintain.
  3. The concept and implementation of “Promises” solves the problem of Callback Hell.
1 Like

1.Synchronous function = Prevents program from executing until they are finished. However, for asynchronous function = Enables multitasking which the function and the program can be executed at the same time.
2. Confusion and complexity of the structure of the code
3.Using promises

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

Synchronous is a function that is always running in the background
While an asynchronous function can be stopped and called back at any given point in the future.

  1. What is callback hell?
    A callback hell is when functions are being run inside other functions within another functions(like a russian nesting doll).

  2. Which technique can help us solve callback hell?

From what I learned so far in this course - writing comments is a good way to clear up what’s going on in a callback hell but this won’t necessarily solve it. So finding ways to break up your long functions into smaller modular functions would probably be another good way.

The article we read mentions that Promises are a good way to solve callback hells. However, at the moment I do not know much about promises so I will do my research on them further.

1 Like