Table of contents
- What is a Server ?
- What it means when we say we are running a website on server ?
- Relation of Java Script and Server ?
- Does Node-JS has C++ code ?
- What is V8 Java Script engine ?
- What is ECMA Script ?
- Does Node JS has V8 embedded on it ?
- When V8 executes any piece of Java Script code why was there need of Node-JS ?
- What are these super powers of Node-JS ?
- Java Script run time ?
- Is V8 written in C++ ?
What is a Server
?
It is a type of system that handles requests from clients and provides services, data, or resources over a network.
Example :
web server likeApache
which hosts websites and serves web pages to user's browsers when they request them via the internet.
What it means when we say we are running a website on server ?
Tt means that the website's files, such as HTML, CSS, images, and scripts, are hosted on a server, which responds to requests from users' browsers by delivering the website's content over the internet. The server processes these requests, allowing the website to be accessible to users online.
In other words it is one CPU or a machine which is receiving the requests and processes these requests.
Relation of Java Script and Server
?
Initially Java Script was the only language which was used inside the browser but after
Node-JS
we can run Java Script on the server.Now Java Script coming on the server as well as the web it gave us an opportunity for a single developer to develop Full Stack Applications.
Java Script engineers can now code using
libraries
andframeworks
likeReact
andAngular
on the client side and using Node-JS on the server side.
Does Node-JS
has C++
code ?
Yes
Node-JS
includesC++
code.Node-JS
is built on top of theV8
Java Script engine which is written in C++.Node.JS
usesC++
for certain performance-critical parts of its runtime.
What is V8 Java Script engine ?
The
V8
engine is an open-source Java Script engine developed byGoogle
, primarily used in theChrome
browser and Node-JS to execute Java Script code. In other wordsV8
isGoogle's
open source high performance Java Script and web assembly engine written in C++.V8
is written in C++. The Java Script Engine uses C++ to execute Java Script Code. 72% majority of the code of V8 is written in C++.The Job of
V8
Engine is to execute Java Script Code.V8
can be embedded into any C++ application.We write Java Script code then it is being read by
V8
which is written inC++
converts the code in which machine understands.V8
engine followsECMA
Script standards.
What is ECMA Script ?
It is standard for Scripting language including Java Script, JS script and Action Script.
All JS engine must follow ECMA Script.
Does Node JS
has V8 embedded
on it ?
Yes,
Node.JS
has theV8
JavaScript engine embedded within it.When we install
Node.JS
, theV8
engine comes bundled with it. This means that when we run aNode-JS
application, our JavaScript code is executed directly by theV8
engine.
When V8 executes any piece of Java Script code why was there need of Node-JS ?
V8
is the engine that executes Java Script code,Node-JS
provides the runtime environment for the use JavaScript for server-side development.Node JS
has V8 engine plus it has a lot more super powers.Node-JS
essentially empowers Java Script to be used as a general-purpose programming language outside of the browser.Node-JS
as a C++ program it hasV8
embedded in it and along with that there are more super powers which it gives and when it runs on the server makes it very powerful.
What are these super powers of Node-JS ?
This can be explained by example , suppose if we have a data base installed and if we want to connect to the data base through Java Script or let us take another example if we want to make
HTTP
call then these super powers comes inform of API and that is the core thing thatNode-JS
adds onto V8Node-JS
with these super powers on top of V8 and this is known as Java Script runtime.Node-JS
: Java Script (62%) + C++(21%).
Java Script run time ?
A Java Script runtime is an environment that allows Java Script code to be executed,. It includes
JavaScript Engine
,APIs
,Event Loop:
andCall Stack
.In other words a Java Script runtime provides everything needed to execute Java Script code and interact with the environment in which it runs, whether that's a
browser (like Chrome)
or aserver (like Node.js)
.
Is V8
written in C++
?
Yes,
V8
is written inC++
. TheV8
Java Script engine is a high-performance engine developed byGoogle
, and it’s primarily written inC++
Computers only understands Binary Code. On top of Binary code there is Assembly code and on top of Assembly code there is High level language. C++ is a high level language.
These C++ code or the Java Script engine takes our Java Script code converts it into a machine code and machine code converts it to a low level code. Machine Code plus Assembly Code is known as low level code.
The code that we write in the higher languages and we need a C++ program or something like a JS Engine that converts our high level code to machine understandable code, which is the job of JS Engine.
In other words,
V8
is aC++
based engine designed to execute Java Script code efficiently by compiling it to machine code.