Little Bit About JavaScript...

Introduction

Brendan Eich is the creator of the JavaScript programming language, who is an American technologist working in Mozilla Corporation. JavaScript is first released on 4th December 1995. JavaScript is an object-oriented programming language used in the web application development process. React js, Angular, Express.js are some popular JavaScript frameworks. Most of the things are based on objects in JavaScript. ECMAScript is the standard followed by JavaScript.

                                  

Comparison between Java and JavaScript

To understand more about JavaScript, consider the below comparison between Java and JavaScript.


JavaScript is an out-of-box language that can run anywhere (servers, browsers, databases, Microservices, Arduino, Raspberry pi, etc.). The most important thing is JavaScript is single-threaded and Java is multi-threaded. Java programming language maintains its concurrency by using multiple threads. (Performance depends on CPU cycles) 

But How JavaScript handle the concurrency? 

Concurrency means the ability that everything is working parallel(almost) inside the processors. Parallel means in this scenario, At a given point of time and but not about the same time
JavaScript is an Asychoronoius language by nature. Asynchronous language simply means language which has some operations that are not in sequential order. 

Sequential Operation: This image shows three statements(Operations). In a sequential means first, execute A and wait for the result and then execute B and wait for the result. After that execute c and wait for the result likewise if there are more operations all these operations are executed in a sequential manner.


Asynchronous Operation: Asynchronous operations are also executed in a sequential manner But can't guarantee that a process is waiting for the executions for a particular statement. As an example from the above image, first, execute the A statement and not wait for the result and go for the B statement.

JavaScript handles its concurrency by this asynchronous nature. CPU operations in javascript are synchronous. But I/O operations like(Network call, Database Read/Write, File Handling, etc.) are asynchronous. Behind the JavaScript Engine, there is a special thread pool to handle the I/O operations. Because of that JavaScript main thread not wait for the completion of I/O operations and the main thread executes on other operations while the thread pool handling the I/O operations. When there is a heavy I/O operation this performs well because of this thread pool. But they not operate well in CPU operations. JavaScript promises are one way of handling asynchronous.

Multithreading Usage in JavaScript

  • Worker threads in JavaScript - This is a new feature introduced from JS13. It Shares the same memory locations and other characteristics.
  • Processes and Forks - These are not actual threads and not share characteristics like a memory location.

ECMAScript

ECMAScript is a programming language standard and commonly used for scripting web pages. This is a JavaScript standard for the responsiveness of web pages in different browsers.


JavaScript Engines in Different Web Browsers

  • Firefox Browser - SpiderMonkey
  • Google Chrome - V8 Engine
  • Microsoft Edge - Chakra
  • Safari - Niro(JavaScriptCore)

References: 
 ----------------------------------------------------------------------------------------------------------------------------

**If there are any questions, mistakes that I made in this blog, or something that needs to be improved in this blog post please be kind enough to know about that from the following form.