Architecture of Java
Java code compiles into platform-independent bytecode(class).
JDK (Java Development Kit)
Used for developing Java applications.
Contains JRE and development tools such as javac, javadoc, and jar.
This bytecode runs inside the Java Virtual Machine (JVM).
The JVM uses a Just-In-Time (JIT) compiler to turn bytecode into native machine code(binary code).
JRE (Java Runtime Environment)
Provides libraries and JVM required to run Java programs.The part of byte code convert into machine code is called JRE.
Source Code (.java)
|
v
Java Compiler
(javac)
|
v
Bytecode (.class)
|
v
JVM(Java Virtual Machine)
|
v
Machine Code
|
v
Operating System
|
v
Hardware
Architecture of Node js
Node.js using chrome v8 engine
=> The V8 Engine
Node.js is a runtime environment built on Google's V8 JavaScript Engine.
It compiles JavaScript code directly into native machine code.
=> Single Thread
Node.js uses a single main thread to process requests.
=> The Event Loop
The heart of Node.js.
Continuously checks for new events and executes callbacks.
=> Event Queue
Stores incoming requests and completed callbacks waiting to be processed.
=> Thread Pool (libuv)
Handles heavy tasks like:
File system operations
Database operations
=> Non-Blocking I/O
Node.js does not wait for one task to finish before processing another.
It can handle multiple requests simultaneously.
Clients
(Browser, Mobile)
|
v
Event Queue
|
v
Event Loop
|
v
Thread Pool
(libuv)
|
v
Operating System
/ File System
/ Database
WORKING :
A client sends a request to the Node.js server.
The request enters the Event Queue.
The Event Loop picks up the request.
If the task is simple the Event Loop handles it directly.
If the task is I/O intensive, it is delegated to the Thread Pool managed by libuv.
Once the task is completed, a callback is placed back in the queue.
The Event Loop executes the callback and sends the response to the client.
Architecture of Python
Python using CPython Interpreter for execution.
The Interpreter: Python is an interpreted language. The source code is compiled into internal bytecode and then executed sequentially by the interpreter.
Unlike java python code doesn't need any explicit compilation(javac), its compile automatically by the interpreter.
Python Code (.py)
|
v
Compiler(Python Interpreter)
|
v
Bytecode (.pyc)
|
v
Python Virtual Machine (PVM)
|
v
Executes Bytecode
|
v
Machine code
|
v
Operating System
|
v
Hardware
Top comments (0)