Synchronous:
- Blocking, single-threaded
- only one operation can progress at a time
- code is executed sequentially from top to bottom, blocking on long running tasks such as network req. and disk I/O.
- result wait and execute sequentially.
- Highly readable code
- easy to implement logic
- cost effective, convenient
- strictly technology based, demandes high speed internet, internet connection, local time barriers, requires careful planning.
- eg: php, java, python
Asynchronous
- Normal js which has some ajax calls which dynamically load data from server without affecting the current flow of execution.
- no wait for result and execute sequentially.
- using asynchronous js (such as callbacks, promises and async/wait), you can perform long network req. without blocking the main thread.
- fast execution
- eg: reactive programming
- hard to implement logic
- eg: javascript, typescript
- no result wait so hard to handle result
- asynchronous result handle (use callback, promise, observable)
- async/await treat js async function as a sync function.
Comments
Post a Comment