Asynchronous Programming - Reading Assignment

  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.

What is the difference between synchronous and asynchronous functions?
-synchronous function needs full attention. Like JavaScript can not do multiple functions at the same time because it single-threading environment.
-asynchronous functions can be put on the side to be executed for a specific time or event.
What is callback hell?
-When complex operations produces several levels and sub-levels.
Which technique can help us solve callback hell?
-In jQuery we can us promises: it enables us to chain call backs and deal with errors.
-In Node.js we can extend the running time example with document.ready

  1. Synchronous has to be finished and then JS will start executing other code, and Asynchronous you can call a function and sort of wait until it will meet the conditions needed.
    2.Callback hell - is the situation you want to avoid. It makes the code harder to maintain and debug.
  2. Technique called promises can help solve it.
  1. In a Synchronous function each task has to finished before starting the next one(First preparing the bed, than go to sleep). In a asynchronous function, you can start with one task and while waiting for the reply, you can work on another task( Putting a pizza in the oven, than watching a game, while waiting the pizza to get ready).

  2. A callback hell is a complex operation produces several levels and sub-levels of reply.

  3. Which technique can help us solve callback hell?

  • In jQuery we can use the built-in promise library.
  • In Node.js we can change the asynchronous function and let it run in a synchronous style (wait).

I had a same problem. I just turned off Brave shields and then it loaded

  1. Synchronous functions lock up the program and will wait until they get the desired answer, while asynchronous function will be able to do other things while still waiting for the information it needed earlier.
  2. A function that calls back a function which calls an another function and so on is what we call a callback hell.
  3. We can use promises which actually comes with JQuery.

What is the difference between synchronous and asynchronous functions?

Synchronous execute until they complete without allowing other code to run.

Asynchronous functions allow other code to run once started, and resume later as defined by the function

What is callback hell?

A term used to refer to growing complexity of code as functions are layered to produce multiple outputs

Which technique can 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. In synchronous programming, each step is performed one after the previous one is finished executing. In asynchronous, step 2 will be performed even if step 1 isn’t finished.
  2. The cause of callback hell is when people try to write JavaScript in a way where execution happens visually from top to bottom.
  3. Solve callback hell:
    A. Don’t nest functions. Give them names and place them at the top level of your program
    B. Use function hoisting to your advantage to move functions ‘below the fold’
    C. Handle every single error in every one of your callbacks. Use a linter like standard to help you with this.
    D. Create reusable functions and place them in a module to reduce the cognitive load required to understand your code. Splitting your code into small pieces like this also helps you handle errors, write tests, forces you to create a stable and documented public API for your code, and helps with refactoring.
  1. What is the difference between synchronous and asynchronous functions?
    When you call a synchronous function your program will wait for a response before it can continue executing. However, an asynchronous function does not provide an immediate response and will therefore allow the calling code to continue executing whilst the function executes in a different thread.

  2. What is callback hell?
    There may be complex systems where multiple asynchronous functions are nested, producing multiple callback levels or, where many asynchronous functions are fired simultaneously. It can be difficult to coordinate correct control flow in such an environment, which leads to a situation known as Callback Hell.

  3. Which technique can help us solve callback hell?
    Whilst jQuery ships with Promises that help chain callbacks for better error handling, using Meteor can extend the Node.js runtime by abstracting the synchronicity aspect of nested functions so as to present them in a synchronous manner.