Asynchronous and Synchronous Terms

13,554

Solution 1

Indeed, it's one of these cases, where original meaning of the word was subverted and means something different than in popular usage.

'Synchronisation' in telecommunication means that receiver signals whenever it is ready to receive messages, and only after this signal the transmitter will start transmitting. When the transmitter is done with the message, it will signal it has finished, so that receiver can now process the received message and do whatever it is supposed to be doing next.

This is of course a simplification and a very broad one, but it should give you the feeling of from where the meaning of '(a)synchronous' comes in JS.

So synchronous request in JS is actually synchronised with the main flow of the program. The program sends request to server ('I'm ready to receive') and waits for message. Message from the server will have a well defined end ('the message ends here - do your job'). When it is received, JS knows it can continue with execution of the program..

Solution 2

synchronous:- when each task connected and depend on the previous task

asynchronous:- each task independent from others.

Solution 3

Synchronous in the context of your question means that 2 parts are waiting for each other.
For example if you have a client code that makes a request to a server and your code does not continue its processing until the response of the server arrives, then this means that your code is synchronous i.e. synchronous with the response of the server.
If your client code makes the request but does not wait for a response and continues its processing and once the response of the request from the server arrives, then your code (in a specific handler for instance) starts to process the response then the handling is asynchronous i.e. the core client processing is asynhronous with the reponse of the server.
These terms imply some short of dependency since it is not possible to convert a synchronous code to asynchronous if (using the example of client-server) the response is mandatory for the client to continue its processing.

Wouldn't something that is "non-blocking" and that allows "the main program flow to continue processing," be synchronized or "occurring at the same time"? It seems like the term synchronous suggests "non-blocking" and asynchronous, "blocking."

Wrong interpretation of the terms. It is not the program flow that synchronized. It is different parts that could be (e.g. threads) or could not be part of the same program that could be synchronized or not.

Solution 4

Synchronous Request: A request is called synchronous when it waits for the response of that particular request before executing the other one. i.e when a client makes a call synchronously then it blocks the client browser to ensure that client couldn’t make another call before getting the server response for that previous call.

Asynchronous Request: An asynchronous call works independently i.e it doesn’t wait for the server response before executing another call or request. so u can simply make different calls at the same time without waiting for the server response.

Share:
13,554
Allen
Author by

Allen

Available for freelance work. Please email [email protected] KEY SKILLS Frontend Development - React, React Native, Vue, Vanilla JavaScript, CSS, Web Components Mobile Development - React Native, Progressive Web Apps, Responsive Web Design Backend Software Engineering - Node.js, Jest, PHP, Ruby, Ruby on Rails, Golang Databases - MySQL, ElasticSearch, MongoDB, Neo4j, DGraph Cloud Technology - AWS, GCP DevOps / Database Administration / Unix / Linux Social Media Integration & APIs Software Architecture and Design Patterns Product Design Web Integrations Web SEO PROJECT HIGHLIGHTS Jolt Software Jolt is a business operations software which focuses mostly on task lists that can be completed by restaurant employees on both the web and on mobile devices. Joined Jolt after they received a round of funding and required seasoned developers to help them “cross the chasm.” Worked across several development teams to write reliable backend software that attracted and secured enterprise customers. Jolt is currently the #1 player in their category. foreUP Golf Software foreUP is a web-based operations software for golf course managers and their employees. Contributed software experience in full-stack development to bring several new product designs to reality for the golf industry. Developed new modules, while also quickly improving upon existing products. Added experience across a range of technologies which allowed foreUP to continue to successfully bootstrap growth. foreUP product page cmiUniverse cmiUniverse is a project management system and a suite of video and 3D editing tools for visual effects artists. Worked closely with talented visual effects artists and video instructors to design and implement an advanced media platform. Quickly programmed web modules for a portion of the cost of developing equivalent native software. View a demo video of cmiUniverse Novelist Software Novelist is a web application that helps authors organize complex characters and plot with timelines. Developed the app from conceptual design to production reality. Built code pipelines, backend and database architectures, and frontend architectures. Insight obtained into the lean startup methodology, while experimenting with and seeking out customer feedback. PROJECT LINKS Website https://mackleystudios.com Portfolio https://mackleystudios.com/portfolio Created Video Training https://www.youtube.com/channel/UCvZDFLvgtL7JvOWpYlOMpzw Created Web App for Writers https://novelistsoftware.com Demo of Created App for VFX Artists https://vimeo.com/62344841

Updated on June 02, 2022

Comments

  • Allen
    Allen almost 2 years

    I'm confused by the term asynchronous when related to programming. It seems to mean the opposite in programming terms as what it is defined as in the dictionary. For example, the word synchronous means:

    1. occurring at the same time; coinciding in time; contemporaneous; simultaneous.

    2. going on at the same rate and exactly together; recurring together.

    Yet, Wikipedia says:

    "In programming, asynchronous events are those occurring independently of the main program flow. Asynchronous actions are actions executed in a non-blocking scheme, allowing the main program flow to continue processing."

    Wouldn't something that is "non-blocking" and that allows "the main program flow to continue processing," be synchronized or "occurring at the same time"? It seems like the term synchronous suggests "non-blocking" and asynchronous, "blocking." Why do the terms appear to be used in reverse when related to programming, or does it have something to do with lower-level computing that I don't understand?

    When I use an synchronous AJAX call, I do the following...

    $.ajax({
      url: somefile.php,
      async: false,
      success: {
        ...code that gets run on success...
      }
    });
    
    ...code that gets run after the ajax-success code runs...
    

    With this, it actually waits for a response before running the rest of the script, it's a blocking action. Then why is this termed synchronous, when it's not synchronized with any other process, but actually the opposite?