Asynchronous Programming - Reading Assignment

1.) Synchronous functions are functions that run until they are completed and Asynchronous functions can be started but then set aside to be completed at a later time so the computer can get started on the next task/command.

2.) Call backhell is when in more complex operations have many different levels and sub-levels of nested functions to task.

3.) The technique used to solve callback hell are called promises or promise libraries like jQuery or to extend runtime with Node.js.

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous functions run in a series of steps where the next step isn’t taken until the current step is completed. Asynchronous functions will run other steps in the background while the current step is waiting for execution.

  2. What is callback hell?
    When the program has to wait for functions to execute, and this results in the program getting bogged down.

  3. Which technique can help us solve callback hell?
    By creating promises with libraries such as Meteor.

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    the synchronous function is executed until its end, without interruptios by another tasks. And usynchronous function is executed, but can be interrupted by another task before it ends.

  2. What is callback hell?
    callback hell is when more complex operations tend to produce even more levels and sub-levels

  3. Which technique can help us solve callback hell?
    promises(juery has promises incleded)

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    Ans: JavaScript is single-threaded which implies that only one section of code can be executed at one time. Functions that only allow one block of code to be executed at a time are called synchronous. Functions that can be initiated and put aside while another code is executed are called asynchronous.

  2. What is callback hell?
    Ans: Callback hell occurs when you have an excessive number of callbacks nested within one another that makes the code look convoluted and can cause confusion.

  3. Which technique can help us solve callback hell?
    Ans: 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 synchronous.

1 Like
  1. Synchronous functions are functions that only excute one section of code at one time. Asynch functions can be initiated and run in the background.

  2. When there are excessive callbacks within callbacks and the code becomes convuluted and confusing.

  3. Promises help us solve callback hell.

1 Like
  1. Synchronous has to complete before the program can continue, Asynchronous means the program can continue and the function can continue once the request is completed.
  2. Large amounts of asynchronous programs making the program very complex.
  3. We can use Promises or timeouts.
1 Like

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

Synchronous functions are executed one after another. Until the current process is executed, the next function has to wait.
Asynchronous functions work a bit differently as they start executing and while they wait for data from an external server for example, the next function can run, and the process gets back to the unfinished function (callback) in the event loop once it’s got the data from the server.

2. What is callback hell?

To run asynchronous functions you need to use nested functions with a special handler. The more complex the task, the more nested functions aka callbacks you end up with. This is called callback hell.

3. Which technique can help us solve callback hell?

Jquery comes with a standard library of so called Promises. This technique is to deal with callback hell.
Other extensions to javascript, like node.js and meteor deal with in a different way. They handle promises and callbacks in the background, and they let the user write synchronous looking code that is interpreted to asynchronous code under the hood.

1 Like

Asynchronous Programming Assignment

  1. Synchronous functionss block code from running until finished with the current block. Asynchronous functions donot block other tasks from completing while waiting for callbacks.
  2. Callback hell is caused by nested functins that become comples and hold up the running of funPromises actions
  3. Promises help alleviate callback hell.
1 Like

1.- Synchronous functions are those that have to run and be completed before the program can move on to other “tasks” or sections of the code. On the other hand, asynchronous functions are those that allow the code to move on to “new tasks” while waiting on the previous task to complete.

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.

3.- A common way to deal with callback hells is with functions called promises.

1 Like

What is the difference between synchronous and asynchronous functions?
Because JavaScript is single threated, it needs asynchronous functions in order to execute multiple commands at once. It sends out a command and gets a promise as it is processing other tasks. This way, JS does not have to wait or clog the browser or the server. It can keep on working and letting it’s assistants send and bring back messages to help running tasks smoothly. So JS is synchronous by nature and it’s functions can only process single operations at once and have to wait until an answer is returned.

What is callback hell?
A traffic jam of multiple operations executed by a programmer. They are nested callbacks which create errors.

Which technique can help us solve callback hell?
Callbacks use “promises” in order to deal with errors. The program Meteor, using “Fibers” package simplifies the code.

1 Like

Ans: 1)
Synchronous in JavaScript coding limits execution to only one call or invoked function at a time. This is commonly known as “blocking,” as the JavaScript engine will only be occupied with this singular function completion before moving on to the next function. The JavaScript engine also gets locked to this functions operation not allowing others to commence. Asynchronous functions do the opposite. They can be started and put to the side while other function processes are also being managed. They do not block up the JavaScript engine, but instead allow it to handle many tasks within the same environment.

Ans: 2)
Callback hell is when many operations or functions are performed which becomes quite complex. The means more requests are made, at any one time, upon a server, to deliver the requested information. Asynchronous functions begin operating to ensure the server or browser does not get fixated upon only performing one execution at a time. This ensures the server or browser is not locked up, with one task until completion, in the JavaScript engine.

Ans: 3)
The technique that can be stored within the browser environment and used to solve call back hell is called “promises.” Promises simply chain our callbacks to systematically, simultaneously deal with these calls whilst high-lighting and isolating any errors or bugs to be dealt with.

1 Like
  1. 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.
  2. 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.
  3. 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.
1 Like
  1. The difference is how they complete the task. the first one do one task and only after the end do another one, whereas asynchronous, if the task requires much time, they don’t wait the response and start the next one in the meanwhile.
    2)It is when the computer have to wait a lot of response from a lot of functions
    3)Promise library
2 Likes
  1. What is the difference between synchronous and asynchronous functions?
    Synchronous functions have to be finished fully executed first and then we move on to the next task. Where asynchronous functions can be put to the side while running so we can directly move on to the next task instead of waiting for the task to be finished.

  2. What is callback hell?
    Callback hell is when we have a lot of nested functions in mostly complex operations.

  3. Which technique can help us solve callback hell?
    To solve callback hell it depends what we work with. In the browser using jQuery there is a built-in library called promise which helps us to chain callbacks and deal with errors. When using Node.js we can write code that looks synchronous by extending the runtime.

1 Like

1.The difference between synchronous and asynchronous functions, is that the synchronous functions need to be finished as soon as they are executed
they are like too important to postpone, and asynchronous functions are functions that dont need to be finished asap, they can wait untill the user
needs them at some point in the future.

2.A callback hell happens when we create operations that have too many layers, making the program too complex, and i suppose too slow too.

3.Theres two techniques to solve callback hell:

Promise: JQuery sends us a promise of delivering results whenever theyre ready, or will tell us if there are problems solving the code, so that Javes
dont have to be solving all this problems.

Meteor: for what i could understand, with meteor we can get an asynchronous function to behave like a synchronous one, by making the code simpler,
i suppose less levels of nesting requieres less computational power.

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

  2. What is callback hell?

  3. Which technique can help us solve callback hell?

  4. Synchronous operations will wait for the result before continuing to execute code.

  5. Stacking of callbacks on different levels and sublevels

  6. We can use promises

1 Like
  1. What is the difference between synchronous and asynchronous functions?
    Answer: Synchronous functions can block any additional functions 'till they finish, while asynchronous functions can be initiated and “set aside” while waiting for a response while allowing other functions to be executed.

  2. What is callback hell?
    Answer: Callback hell refers to having a series of nested functions that rely on each other to complete said task.

  3. Which technique can help us solve callback hell?
    Answer: Using ‘promises’ in jQuery enables us to chain callback and deal with errors. In Node.js, you can abstract asynchronicity to extend runtime and build a synchronous equivalent function.

1 Like
  1. synchronous functions execute one at a time, so each function must run and completely finish running before the next function can be executed. Asynchronous functions on the other hand can begin running when they are executed but then they allow the program to move on to executing the next block of code while they are still running.
  2. Callback hell is when your code contains a lot of nested functions inside other nested functions so each function is waiting for other functions to execute. If someone tried reading through this code it would just look like a crazy mess.
  3. We can use the Promise library that is included in many libraries such as jQuery.
1 Like
  • What is the difference between synchronous and asynchronous functions?
    The synchronous function will execute one task beginning to an end however long the task may take. The asynchronous function will leave start a task left in the middle and come back to that task when it is better suitable to do so.
  • What is callback hell?
    Call back hell is when the un-finished functions come back at the same time whit a lot of shit that clogs the system.
  • 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 deals 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 synchronous.

1 Like
  1. Synchronous code means each statement in our code is executed one after the other. This means each statement has to wait for the previous one to finish executing.
    Asynchronous code takes statements outside of the main program flow, allowing the code after the asynchronous call to be executed immediately without waiting.

  2. Callback hell is any code where the use of function callbacks becomes difficult to follow because of many levels and sub-levels.

  3. A common pattern to deal with excessive callbacks is to use promises. There’s a simple built-in promise library built into jQuery that enables us to chain callbacks and deal with errors.

1 Like