Asynchronous Programming - Reading Assignment

What is the difference between synchronous and asynchronous functions?

synchronous is one function at a time it lock up the browser for the duration of its execution, asynchronous is multiple functions at a time you ,can do other functions while one is running

What is callback hell?

a simple operation that require a lot of nested a lot of nested functions, a repetition of callback that create too much coding

Which technique can help us solve callback hell?

with promises or meteor with fibers package

1 Like
  1. Synchronous functions does not allow the program to continue until something is finished and Asynchronous ones allows the execution of other tasks in different threads regardless of the program doing previous tasks pending to be finished.
  2. This happens when asynchronous functions are not possible to execute because they are waiting for other nested functions to finish, basically blocking the entire program.
  3. With a function called “promise” (that can deal with the related errors as the program keeps running)
1 Like
  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?
    event handlers allow our code to become asynchronous, but can leave our code open to becoming overly complex and difficult to read

  3. Which technique can help us solve callback hell?
    Promises

1 Like
  1. Synchronous operations in JavaScript entails having each step of an operation waits for the previous step to execute completely. This means no matter how long a previous process takes, subsequent process won’t kick off until the former is completed. Asynchronous operations, on the other hand, defers operations. Any process that takes a lot of time to process is usually run alongside other synchronous operation and completes in the future.

  2. Callback Hell , also known as Pyramid of Doom, is an anti-pattern seen in code of asynchronous programming. It is a slang term used to describe and unwieldy number of nested “if” statements or functions.

  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
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous functions occur one after the other and don’t allow the next function to begin executing until the previous one has finished. Asynchronous functions on the other hand will allow the other functions to begin before it has completed all of its tasks. For instance, if a function needs to wait for a server to respond, it will happily begin executing the next function and continue with the previous one when the response comes through.

  2. What is callback hell?
    callback hell is the confusioin and complexity in code that quickly escalates when using asynchronous callback functions.

  3. Which technique can help us solve callback hell?
    You can prevent a callback hell with so called promises this makes it easier

1 Like
  1. Synchronous functions must be executed in order of presentation and it needs full attention until its completed, where as asynchronous functions can have delays while being called.

  2. A callback hell is when there are too many nested functions, with different levels and sub-levels which complicates the program causing difficulty in readability.

  3. Callback hell can be solved by using promises libraries which can chain callbacks and deal with errors.

1 Like
  1. Synchronous code executes code from top to bottom, one at a time. Asynchronous code executes the same way until it reaches something asynchronous - executes THAT, and the rest of the code. Asynchronous can potentially execute code at different times, every time. An example fo asynchronous code is the setTimeout function, which synchronously will read this code, but execute at its specified time. Most functions that take functions as arguments are asynchronous.

  2. Callback hell is when you have arguments that call upon other arguments and cannot execute until the nested functions within nested functions complete their tasks. The code can get really messy and very hard to fix if an issue arises.

  3. Techniques that help solve callback hell are called “promises,” which libraries like jQuery have included in them that deal with errors, etc.

1 Like

Asynchronous Programming - Reading Assignment.

  1. The difference between synchronous and asynchronous functions is, synchronous function task required a browser full attention until it is completed. while asynchronous function task can be initiated and then put aside until a later date while other tasks are started.

  2. A Callback Hell is when simple operation requires three or more levels of nested functions which in turn produce more levels and sub levels of tasks.

  3. The technics that can help us solve callback hell are:

  • promise - a jQuery Library that enable us to chain callbacks and deal with errors.
  • nodejs - extension of runtime to extract away the asychronicity and write code that looks synchronous. For example fibre by Meteor.
1 Like
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous function can execute only one task at the same time.
    Asynchronous function can be initiated whereas synchronous will occupy javes continuously until its completion.

  2. What is callback hell?
    When some complex operations require three levels or more of nested functions and sub-levels, that’s called callback hell.

  3. Which technique can help us solve callback hell?
    To deal with the excessive callbacks we have to use promises. jQuery ships with a simple built-in promise library that enables us to chain callbacks and deal with the errors.

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    A synchronous function allows use to do one thing at a time, they will only focus on this until that function is finished. Whereas a asynchronous function allows use to manage different tasks.
  2. What is callback hell?
    The fact that severeal callbacks are implied, makes our code very complex to read.
  3. Which technique can help us solve callback hell?
    One technique to avoid calbback hell are promises.
1 Like
  1. What is the difference between synchronous and asynchronous functions?

A synchronous functions will be executed one by one, waiting to the previous one to be executed. An asynchronous function can be executed in a parallel thread without waiting.

  1. What is callback hell?

Callback hell is a bad practice programming where the code reaches a point with multiple levels of nested functions, difficulting the readability, maintainability and debugging.

  1. Which technique can help us solve callback hell?

Using the promises library from JQuery.

1 Like
  1. Synchronous functions require full attention from the JavaScript engine and must be completed prior to moving on. Asynchronous functions do not block the thread and are able to wait for response from say a server, while the thread works on other tasks.

  2. Callback hell refers to several nested callback functions being needed to complete simple tasks.

  3. To solve callback hell we can use promises.

1 Like

1 Synchronous functions block the program’s further execution until something is done while Asynchronous functions do not block the program.
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

1 Like
  1. synchronous task will occupy javes continuously until its completion, an asynchronous task can be initiated then put aside until a later date while our valet gets started on the next task

  2. More complex operations tend to produce more levels of sub-levels, known as callback hell

  3. using a jQuery library called promises to chain callbacks and deal with errors

1 Like
  1. synchronous - is when the program executes one task at a time, which is fine for simple/quick tasks; asynchronous tasks can initiate a task, put it aside, and then initiate and execute another when tasks take more time to complete i.e. querying 3rd party server.
  2. callback hell - nested functions with many levels and sublevels that make it difficult to deal with errors/bugs in the code
  3. jQuery’s built in promise library enables us to chain callbacks which help deal with errors
1 Like
  1. What is the difference between synchronous and asynchronous functions?
    The difference between synchronous and asynchronous is the ability to multi-task. Synchronous does not permit it. Asynchronous does. But it is more like asynchronous allows you to start something with someone else and leave until they respond while synchronous forces you to wait for them to respond.

  2. What is callback hell?
    A callback is when you have one function calling another function and waiting for it to finish before continuing. Callback hell is when these dependencies are nested deeply or unfinished callbacks start piling up. Eg: waiting to see if a url is available on the internet can sometimes take a few seconds.

  3. Which technique can help us solve callback hell?
    Not sure I have this right but here is how I understand it:
    One technique is to use a Promise object. A promise is created by the called function by immediately creating a Promise object and assigning it a ‘pending’ status. Then the called function goes off to complete its purpose (eg: open a file). When the event completes it updates the Promise’s status (eg: ‘done’). During the whole process this Promise record is like a liaison, a place to look to check the status. Promise objects are available in JQuery.

1 Like

What is the difference between synchronous and asynchronous functions?

Synchronous functions will block the entire system where the Javascript code is running until the function has executed completely. Asynchronous functions will initialize the function then let the system free to do whatever it wants until that async function is “calling back” that it is ready to execute the last piece of code.

What is callback hell?

It is when a program contains several asynchronous functions that is nested together and create a complex chain of asynchronous functions passed as arguments to the next one.

Which technique can help us solve callback hell?

Using promises to chain together multiple callbacks. This will make it easier to maintain several levels of callbacks.

1 Like
  1. Synchronus programming ties up the program while asynchronous allows background rendering.

2.call back hell is when the program is tied up waiting on a response before it can complete.

  1. Promises are like digital guarantees and makes sure the program completes the task u leave to it
1 Like
  1. a) synchronous functions execute after each other, only 1 is being executed in the same time and the first function must be fully executed before the program continues with the second function
    b) in contrast with a), asynchronous functions mean that while the first function executes, the second function can also start to execute (before the first one fully executed) if the value produced by function1 is not needed for function2
  2. callback hell is when there are many many sub-levels to a complex operation
  3. promises (OR extending runtime in Node.js)
1 Like
  1. The difference is that Synchronous Functions that contain multiple commands will run those commands one at a time, while the Asynchronous function that contains multiple commands will not wait for one command to finish before running the next but they run immediately.

  2. Callback hell is a situation that caused by coding with complex nested callbacks, where the code structure looks like a pyramid, making it difficult to read and maintain becouse each and every callback takes an argument that is a result of the previous callbacks.

  3. An easy way to solve a callback hell is to use promises, a simple built-in promise library that enables us to chain callbacks and deal with errors.

1 Like