Asynchronous Programming - Reading Assignment


#81

I was wondering if we needed to understand all the code used in the examples or just skim through it to kinda see what’s happening

  1. What is the difference between synchronous and asynchronous functions?
    Synchronous functions take immediate attention and must finish before working on something else. Asynchronous functions can be put aside until it becomes efficient for it to be ran or the resources exist to run it are available

  2. What is callback hell?
    It’s when complex operations rely on a vast depth of nested functions making debugging impossible

  3. Which technique can help us solve callback hell?
    jQuery has a promise library that chains callbacks to deal with errors
    Node.js can extend runtime in order to abstract away asychonicity
    Meteor uses Fibers package which lets you write code in a synchronous style


#82
  1. Synchronous functions are those that run in a sequence. One function has to finish before the next one can be run.
    Asynchronous functions are those that can be run at the same time or a function can start or complete whilst another function is running.
  2. Call back hell is where functions have to deal with other functions no completing in sequence or producing errors whilst they are running at the same time.
  3. Promises are a way of dealing with callback hell. Promises assign a state to the function pending or fulfilled or rejected.

#83

1- Synchronous functions are those that occupy the Javascript engine until they are fully executed. Asynchronous functions on the other hand can be partially executed while the engine works on other tasks, only to come back to the these operations when they are ready to be continued.
2- Callback hell is a situation where multiple functions are waiting for other functions which in turn wait for other functions and it makes code harder read, write, and debug.
3- A common way in Javascript to deal with callback hell is to use promises, which are used to deal with the result of an asynchronous operation.


#84
  1. Synchronous refers to tasks that are completed one after another(one at a time, in other words, continuous until completion). Asynchronous tasks can be initiated and then put aside until a later time.

  2. Multiple callbacks within each other…

3.Promises


#85
  • The difference between Synchronous and Asynchronous functions is related to the time and order they are executed. If functions must be executed one after an other, that’s a synchronous environnement. If more than one function can be executed along each other, the environnement allows asynchronous functions.
  • Callback hell refers to functions waiting within an other function who is waiting within an other function waiting, and so on… At one point it becomes hell to read the code.
  • To deal with callback hell, one can use jquery libraries like “Promises” to deal with them without locking the browser while waiting for external sources reply.

#86
  1. Javas script is single-threaded environment. Asynchronous functions allow us to schedule tasks.
  2. Code with many nested callback.
  3. By use promises that allowed us to chain call backs

#87
  1. in a synchronous function, the code is executed but in fact “blocks” other code execution until the function completes. In the async example however the code starts execution but then goes into a non blocking state and is reactivated with a callback when the event you are waiting on completes.
  2. What is callback hell?
    Nested event handlers that indeed make the flow asynchronous, but in turn make the code overly complex and difficult to read.
  3. using built-in promises that allow better management of callback complexities.

#88

copy paste
Synchronous functions are those that are ‘blocking’ that is to say that they occupy the Javascript engine until their execution is finished. Asynchronous function on the other hand do not block the Javascript thread, instead they wait for execution to complete while the thread does other work.

Callback hell is an undesirable situation whereby several nested callback functions are needed in order to perform relatively simple tasks. This makes our code harder to write, debug and maintain.

We can use promises to solve the problem of call back hell. Promises help us to deal with chained synchronous functions and allows us to also handle errors. Modern javascript libraries and frameworks like Angular and jQuery come with a promise library. Another way of dealing with callback hell in Node.js is to extend the runtime and and abstract away the asynchronicity so as to allow the programmer to write asynchronous code in a synchronous style.


#89

What is the difference between synchronous and asynchronous functions?

Synchronous functions can only be done in order, complete one do two, asynchronous function can be waited on, do one wait on two do three while wait.

What is callback hell?

Multitude of nested functions that tend to produce more levels and sub-levels are called callback hell.

Which technique can help us solve callback hell?

Most common technique is to use promises library


#90
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous functions would continue to execute functions in turns an would not continue to the coming code until the previous code is done. So, if a function takes a lot of time due to obtaining information it would just wait until the execution are done. Asynchronous functions would instead of waiting for an answer from example a different computer then continue with the upcoming code until a message/signal of the answer has arrived and it would then complete the earlier code that was paused.
    So, synchronous functions take one task after the other, as asynchronous functions has the ability of pausing a function when code are not complied to continue to compile the coming code until the function paused are ready to continue.

  2. What is callback hell?
    Callback is when a function has to wait a certain amount for time or for anything to happen before the code can be executed.

    Callback hell are when callbacks are nested, that would say that you have functions and code executed inside the callback and potentially even more callbacks inside these again. To be able to know where to continue and pick up again you need a event loop that tracks where to go back to. Callback inside callbacks in many levels could fast be messy and are therefor called callback hell.

  3. Which technique can help us solve callback hell?
    In the browser, a common pattern to deal with excessive callbacks is to use promises.

    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 synchronous.


#91
  1. Synchronous functions occupy the browser continously until completion, asynchronous functions can be initiated and then put aside.

  2. Complex operations that produce levels and sub-levels.

  3. Promises, or extending the runtime and write code that looks synchronous.


#92
  1. Synchronous functions don’t wait for asynchronous functions to finish and goes to the next tasks and this could lead to a problem simply because sometimes we need to wait for some data or some update. Asynchronous function waits until it receives the response than acts accordingly.

  2. But this can lead to the something called callback hell. So, everytime a code waits for something, this could take a lot of time.

  3. The way to solve this, using promises or different packages like fibers.


#93
  1. What is the difference between synchronous and asynchronous functions? Synchronous functions are those that occupy the Javascript engine until they are fully executed and an Asynchronous task can be initiated and then put aside until a later.

  2. What is callback hell?
    Callback hell is when several nested callback functions are needed in order to perform relatively simple tasks. This makes the code complex and difficult to read.

  3. Which technique can help us solve callback hell?
    Using the promises library


#94

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 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?
Nested 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?
There are a few options to help us deal with callback hell. One being the use of promises , which enables us to chain callbacks and deal with errors.


#95

What is the difference between synchronous and asynchronous functions?
Synchronous functions can block/ let the JavaScript engine wait until it has finished execution of the function. Asynchronous functions are started by the JavaScript engine and then put aside for completion at a later time.

What is callback hell?
The multitude of levels of nested functions

Which technique can help us solve callback hell?
The use of a promise library


#96

1 Synchronous is when one task is done after the other.
Asynchronous is when you have to post-pone a task, because you can’t complete it at the current moment.

2 When there is a lot of nested functions waiting for callbacks, becoming complex operations.

3 In jQuery we use promises.
In Node.js we can extending runtime and abstracting away asynchronicity, we write code that looks synchronous.


#97

What is the difference between synchronous and asynchronous functions? : synchronous code runs according to a single process; an asynchronous code can be initiated and then put aside until a later date while our other code is run
What is callback hell? : Endless levels of nested asynchronous functions
Which technique can help us solve callback hell? : Simulate synchronicity using fibers


#98
  1. A synchronous function can only handle one task at a time and blocks the program from completing any further tasks. While asynchronous functions allows you to handle multiple tasks simultaneously without blocking the program.

  2. Callback hell is having callback after callback after callback.

  3. We can deal with them using promises.


#99

Synchronous loading occurs when the browser must halt the rendering of the page in order to complete the execution of JavaScript code. When the browser encounters a synchronous JavaScript tag, it blocks the page from rendering until the code execution completes.

Asynchronous JavaScript code is processed in parallel to the rest of the page content. This means that even if a vendor tag is slow to respond or to load, it will not slow down the rest of the page.

JavaScript tags load independently from each other, the asynchronous method minimizes the impact of loading external JavaScript files on the page rendering process.

Callback Hell is a term used to describe multiple levels of nested functions.

One strategy is to use Promises and another is to extend run time to help solve callback hell.


#100
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous function runs one piece of code at a time before the next code can be executed. Asynchronous function can be ran/written at the same time another code has been executed.

  2. What is callback hell?
    “Call back hell”; also known as the “Pyramid of doom” containing multiple, complex asynchronous codes that are tough to manage the flow.

  3. Which technique can help us solve callback hell?
    Promises allows us to chain callbacks and deal with errors, which helps make the code easier to read and manage.