Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
18 views

Programming Languages Assignment

Uploaded by

sarvesharmy6809
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Programming Languages Assignment

Uploaded by

sarvesharmy6809
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Programming Languages Assignment

class Main{
public static void main(String args[]){
System.out.println(
"@Author : Prashanth Kumar \n"+
"@Roll : 22/11/EC/050 "
);
}
}

Java Runtime Structure

Java Runtime Environment (JRE)


JRE provides a runtime for executables, eliminating the need for platform-specific code. It combines
Java code with libraries to create a JVM instance that runs Java programs. This enables platform
independence, allowing Java applications to be written once and run anywhere.

Memory Management
In Java, objects are stored in Heap space, while Stack memory contains references to these objects.
Heap memory is used globally, while Stack memory is used by a single execution thread.

Class Loading
The Java Class Loader, part of the JRE, dynamically loads Java classes into the JVM as needed. It
consists of:
Bootstrap Class Loader: Loads core Java libraries.
Extension Class Loader: Loads classes from extension directories.
Application Class Loader: Loads classes from the classpath, including user-defined classes and
libraries.
image source : Google Search

Execution Engine
The Java Execution Engine is responsible for executing Java bytecode, which is the compiled form of
Java source code. The components of the Java Execution Engine include the Class Loader, Bytecode
Verifier, Just-In-Time (JIT) Compiler, and the Java Virtual Machine (JVM).

Feature Interpretation JIT compilation

Executes bytecode directly by the Translates bytecode into native machine


Process
JVM. code at runtime, just before execution.

Execution Interprets each bytecode Translates entire methods or functions


StyleProcess instruction one at a time. into native code for execution.

Generally slower as it does not Can be faster as it allows execution in


Execution Speed take full advantage of hardware native machine code, optimizing for the
features. underlying hardware.

Platform-independent in terms of
Platform Platform-independent, as
bytecode, but the generated native code
Independence bytecode is executed by the JVM.
is platform-specific.
Feature Interpretation JIT compilation

Typically easier to debug, as the Debugging can be more challenging, as


Debugging execution is closer to the original the executed code is in native machine
source code. language.

May have faster startup time, as May have a slight delay in startup time
Startup Time
there is no initial compilation step. due to the compilation process.

Generally lower memory usage, as


May have higher memory usage due to
Memory Usage there is no need to store native
the storage of generated native code.
code.

Generally lower performance Can provide higher performance,


Performance
compared to JIT compilation. especially for frequently executed code.

JVM - Detailed Study:

JVM architecture (Source : freecodecamp)

The Java Virtual Machine (JVM) is part of the Java Runtime Environment (JRE) that executes Java
bytecode, abstracting the hardware and OS for platform independence. This allows Java applications to
run on any device or OS with a JVM, supporting Java's "write once, run anywhere" principle.
Platform Independence:
JVM executes compiled Java bytecode, not native machine code, making Java a platform-independent
language. This facilitates the portability of Java applications across various platforms.

JVM Memory Areas:


JVM manages memory through several areas:

Method Area: Stores class structures, method data, field data, and static variables.
Heap: Manages object instances memory.
Java Stack: Contains method-specific data, including local variables and partial results.
PC Register: Tracks the program counter, pointing to the current instruction.
Native Method Stack: Stores native method information and data. These areas support memory
allocation and deallocation during program execution.

Image Source : javatpoint

Garbage Collection:
Garbage collection is an automatic process that reclaims memory from unused objects. Various garbage
collection algorithms exist, each with a different approach to balancing memory reclamation efficiency
and application responsiveness.

Java Native Interface (JNI):


The Java Native Interface (JNI) allows Java code to interact with applications and libraries in other
languages, such as C and C++. It provides a bridge for seamless integration, enhancing the flexibility and
extensibility of Java applications.

Features of Functional and Imperative Languages


Functional Languages:

Functional vs Imperative Languages

Functional Languages:
Functional languages emphasize immutability, first-class and higher-order functions, pure functions,
recursion, and referential transparency. Examples include Haskell, Clojure, and Erlang.

Imperative Languages:
Imperative languages allow mutable state, procedural statements, explicit control flow, and may involve
side effects. They often require explicit synchronization in concurrent settings.

In summary, functional programming promotes immutability and declarative constructs, while imperative
programming allows mutable state and explicit control flow.

Typed and Untyped Languages

Untyped Languages:
Untyped or dynamically typed languages don't require explicit type annotations. Variables can change
types during runtime, offering flexibility and rapid prototyping. However, they may lead to runtime errors
and reduced readability.

Examples:

JavaScript: Used for web development and client-side scripting.


Python: Used for general-purpose programming, data science, and AI.

Simply Typed Languages:


Simply typed languages enforce strong typing with a simple type system. They ensure operations are
performed on correct types, preventing unintended conversions and enhancing reliability.

Examples:

Java: Requires explicit type declarations and performs type checking at compile-time. Used for
enterprise applications and Android development.
C# (C Sharp): Strongly typed and supports static type checking. Used for Windows application
development and game development using Unity.
Swift: A statically typed language combining strong typing with type inference. Used for iOS and
macOS application development.

References
simplesnippets
digital oceam
FreeCodeCamp
AWS
Microsoft

Assignment Made With Markdown and converted to pdf with md2pdf

You might also like