21CSC203P / ADVANCED PROGRAMMING PRACTICE
UNIT I
BY
Dr. J. SUTHA
PROFESSOR & HoD
DEPARTMENT OF CSE,
SRM IST, RAMAPURAM.
COURSE OBJECTIVES
The purpose of learning this course is to:
• Understand the paradigm functionalities and their hierarchy.
• Deploy structural, procedural, and Object-Oriented Programming Paradigm.
• Demonstrate the event, Graphical User Interface, and declarative Paradigm
with a java application.
• Extended knowledge on logic, functional, network and concurrent Paradigm.
• Symbolic, Automata-based, and Event with a python application.
DEPT. OF CSE, SRMIST
2
21CSC203P - ADVANCED PROGRAMMING PRACTICE
COURSE OUTCOMES
At the end of this course, learners will be able to:
CO-1 : Devise solutions to the various programming paradigm.
CO-2 : Express proficiency in the usage of structural, procedural, and ObjectOriented Program.
CO-3 : Determine the Java application using declarative, event, and graphical
user interface paradigm.
CO-4 : Express proficiency in the usage of logic, functional, network, and
concurrent Paradigm .
CO-5 : Determine the Python application using symbolic, automata-based, and
graphical user interface programming paradigms.
DEPT. OF CSE, SRMIST
3
21CSC203P - ADVANCED PROGRAMMING PRACTICE
UNIT - 1
Unit-1 - Introduction to Programming Paradigm
Programming Languages – Elements of Programming languages - Programming
Language Theory - Bohm- Jacopini structured program theorem - Multiple
Programming Paradigm – Programming Paradigm hierarchy – Imperative
Paradigm: Procedural, Object-Oriented and Parallel processing – Declarative
programming paradigm: Logic, Functional and Database processing - Machine
Codes – Procedural and Object-Oriented Programming – Suitability of Multiple
paradigms in the programming language - Subroutine, method call overhead and
Dynamic memory allocation for message and object storage - Dynamically
dispatched message calls and direct procedure call overheads – Object
Serialization – parallel Computing
DEPT. OF CSE, SRMIST
4
21CSC203P - ADVANCED PROGRAMMING PRACTICE
OUTLINE OF THE PRESENTATION
S-3
What is Programming Languages?
S-5
Elements of Programming languages
S-7
Programming Language Theory
S-9
Bohm- Jacopini structured program theorem
S-13
Multiple Programming Paradigm
S-15
Programming Paradigm hierarchy
S-18
Imperative Paradigm: Procedural, Object-Oriented and Parallel processing
S-22
Declarative programming paradigm: Logic, Functional and Database
processing - Machine Codes-Procedural and Object-Oriented Programming
S-24
Suitability of Multiple paradigms in the programming language
S-27
Subroutine, method call overhead and Dynamic memory allocation for
message and object storage
S-30
Dynamically dispatched message calls and direct procedure call overheads
S-33
Object Serialization
S-35
Parallel Computing
DEPT. OF CSE, SRMIST
5
21CSC203P - ADVANCED PROGRAMMING PRACTICE
WHAT IS PROGRAMMING LANGUAGES?
• Programming languages are formal languages designed to communicate instructions to a computer system or a
computing device.
• They serve as a means for humans to write programs and develop software applications that can be executed by
computers.
• Each programming language has its own syntax and set of rules that define how programs should be written.
• Programming languages can be classified into different types, including:
1. Low-Level Languages
2. High-Level Languages
3. Scripting Languages
4. Object-Oriented Languages
5. Functional Languages
6. Domain-Specific Languages (DSLs)
DEPT. OF CSE, SRMIST
6
21CSC203P - ADVANCED PROGRAMMING PRACTICE
1.Low-Level Languages: These languages are close to machine code and provide little or no
abstraction from the computer's hardware. Examples include assembly languages and
machine languages.
2.High-Level Languages: These languages are designed to be closer to human language and
provide a higher level of abstraction. They offer built-in functions, libraries, and data
structures that simplify programming tasks. Examples include C, Python, Java, C++, C#,
and Ruby.
3.Scripting Languages: These languages are often interpreted rather than compiled and are
used to automate tasks or perform specific functions within a larger program. Examples
include Python, Perl, Ruby, and JavaScript.
DEPT. OF CSE, SRMIST
7
21CSC203P - ADVANCED PROGRAMMING PRACTICE
WHAT IS PROGRAMMING LANGUAGES?
4.
Object-Oriented Languages: These languages emphasize the concept of objects, which encapsulate
both data and the functions (methods) that operate on that data. Examples include Java, C++, C#,
and Python.
5.
Functional Languages: These languages treat computation as the evaluation of mathematical
functions and avoid changing state or mutable data. Examples include Haskell, Lisp, and Erlang.
6.
Domain-Specific Languages (DSLs): These languages are designed for specific domains or problem
areas, with specialized syntax and features tailored to those domains. Examples include SQL for
database management, HTML/CSS for web development, and MATLAB for numerical computing.
• Programming languages have different strengths and weaknesses, and developers choose a language
based on factors such as project requirements, performance needs, development speed, community
support, and personal preference. Learning multiple languages can give programmers flexibility and
allow them to solve different types of problems more effectively.
DEPT. OF CSE, SRMIST
8
21CSC203P - ADVANCED PROGRAMMING PRACTICE
ELEMENTS OF PROGRAMMING LANGUAGES
• Here are the fundamental elements commonly found in programming languages:
1.Variables: Variables are used to store and manipulate data during program execution.
They have a name, a type, and a value associated with them. Programming languages may
have different rules for variable declaration, initialization, and scoping.
2.Data Types: Programming languages support various data types, such as integers,
floating-point numbers, characters, strings, booleans, arrays, and more. Data types define
the kind of values that can be stored and manipulated in variables.
3.Operators: Operators perform operations on data, such as arithmetic operations (addition,
subtraction, etc.), comparison operations (equal to, greater than, etc.), logical operations
(AND, OR), and assignment operations (assigning values to variables).
DEPT. OF CSE, SRMIST
9
21CSC203P - ADVANCED PROGRAMMING PRACTICE
ELEMENTS OF PROGRAMMING LANGUAGES
4. Control Structures: Control structures allow programmers to control the
flow of execution in a program. Common control structures include
conditionals (if-else statements, switch statements), loops (for loops, while
loops), and branching (goto statements).
5. Functions and Procedures: Functions and procedures are reusable
blocks of code that perform a specific task. They take input parameters,
perform computations, and optionally return values. Functions and
procedures facilitate modular and organized programming.
DEPT. OF CSE, SRMIST
10
21CSC203P - ADVANCED PROGRAMMING PRACTICE
6. Expressions: Expressions are combinations of variables, constants, operators, and
function calls that evaluate to a value. They are used to perform calculations, make
decisions, and manipulate data.
7. Statements: Statements are individual instructions or commands in a programming
language. They perform specific actions or control the program's behavior. Examples
include variable assignments, function calls, and control flow statements.
8. Syntax: Syntax defines the rules and structure of a programming language. It
specifies how programs should be written using a specific set of symbols, keywords,
and rules. Syntax determines the correctness and readability of the code.
DEPT. OF CSE, SRMIST
11
21CSC203P - ADVANCED PROGRAMMING PRACTICE
9. Comments: Comments are used to add explanatory or descriptive text within the
code. They are ignored by the compiler or interpreter and serve as documentation for
programmers or readers of the code.
10. Libraries and Modules: Libraries or modules are prewritten collections of code that
provide additional functionality to a programming language. They contain reusable
functions, classes, or other components that can be imported into programs to extend
their capabilities.
• These are some of the core elements of programming languages. Different
programming languages may have additional features, syntax rules, or concepts
specific to their design and purpose.
DEPT. OF CSE, SRMIST
12
21CSC203P - ADVANCED PROGRAMMING PRACTICE
PROGRAMMING LANGUAGE THEORY
• Programming Language Theory is a field of computer science that studies the design, analysis, and
implementation of programming languages. It focuses on understanding the principles, concepts, and
foundations that underlie programming languages and their use.
• Programming Language Theory covers a broad range of topics, including:
• Syntax and Semantics: This area deals with the formal representation and interpretation of
programming language constructs. It involves defining the syntax (grammar) of a language and
specifying the meaning (semantics) of its constructs.
• Type Systems: Type systems define and enforce the rules for assigning types to expressions and
variables in a programming language. They ensure type safety and help catch errors at compile-time.
DEPT. OF CSE, SRMIST
13
21CSC203P - ADVANCED PROGRAMMING PRACTICE
PROGRAMMING LANGUAGE THEORY
• Programming Language Design and Implementation: This aspect involves the process of creating
new programming languages or extending existing ones. It explores language features, constructs, and
paradigms, and how they can be efficiently implemented.
• Programming Language Semantics: Semantics concerns the meaning and behavior of programs. It
involves defining mathematical models or operational semantics to formally describe program execution
and behavior.
• Programming Language Analysis: This area focuses on static and dynamic analysis of programs,
including type checking, program verification, optimization techniques, and program understanding.
• Formal Methods: Formal methods involve using mathematical techniques to analyze and prove
properties of programs and programming languages. It aims to ensure correctness, safety, and reliability
of software systems.
DEPT. OF CSE, SRMIST
14
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• Language Paradigms: Programming Language Theory explores different programming paradigms,
such as procedural, object-oriented, functional, logic, and concurrent programming. It investigates the
principles, strengths, and limitations of each paradigm.
• Language Implementation Techniques: This aspect covers compiler design, interpretation, code
generation, runtime systems, and virtual machines. It investigates efficient strategies for executing
programs written in various programming languages.
• Language Expressiveness : Language expressiveness refers to the power and flexibility of a
programming language in expressing different computations, algorithms, and abstractions. It explores the
trade-offs between expressiveness and other factors such as performance and readability.
• Programming Language Theory provides the foundation for understanding and reasoning about
programming languages. It helps in the development of new languages, designing better programming
constructs, improving software quality, and building efficient and reliable software systems.
DEPT. OF CSE, SRMIST
15
21CSC203P - ADVANCED PROGRAMMING PRACTICE
BÖHM-JACOPINI THEOREM
• The Böhm-Jacopini theorem, formulated independently by Corrado Böhm and Giuseppe
Jacopini, is a fundamental result in programming language theory.
• It states that any computation can be performed using only three basic control structures:
sequence, selection (if-then-else), and iteration (while or for loops). This means that any
program, regardless of its complexity, can be expressed using these three control
structures alone.
• The theorem is significant because it establishes that more complex control structures,
such as goto statements or multiple exit points, are not necessary to express any algorithm.
• By limiting the control structures to sequence, selection, and iteration, the theorem
promotes structured programming, which emphasizes readable and modular code.
DEPT. OF CSE, SRMIST
16
21CSC203P - ADVANCED PROGRAMMING PRACTICE
To understand the Böhm-Jacopini theorem, let's look at the three basic control structures
it allows:
Sequence: This control structure allows a series of statements to be executed in a specific
order, one after another. For example:
Statement 1;
Statement 2;
Statement 3;
Selection (if-then-else): This control structure enables a program to make decisions
based on certain conditions. It executes one set of statements if a condition is true and
another set of statements if the condition is false.
DEPT. OF CSE, SRMIST
17
21CSC203P - ADVANCED PROGRAMMING PRACTICE
For example:
if (condition) {
Statement 1;
} else {
Statement 2;
}
Iteration (while or for loops): This control structure allows a set of statements to be
repeated until a certain condition is satisfied. It executes the statements repeatedly as
long as the condition holds true.
For example:
while (condition) {
Statement;
}
DEPT. OF CSE, SRMIST
18
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• The Böhm-Jacopini theorem states that any program can be structured using these three
control structures alone. This means that complex programs with loops, conditionals, and
multiple branches can be rewritten using only sequence, selection, and iteration constructs.
• The theorem assures that these basic structures are sufficient to express any algorithm or
computation, promoting clarity and simplicity in program design.
• While the Böhm-Jacopini theorem advocates for the use of structured programming principles,
it is important to note that modern programming languages often provide additional control
structures and abstractions to enhance code readability and maintainability.
• These higher-level constructs build upon the foundations established by the theorem but allow
for more expressive and efficient programming
• The Böhm-Jacopini theorem, also called structured program theorem, stated that working out a
function is possible by combining subprograms in only three manners:
DEPT. OF CSE, SRMIST
19
21CSC203P - ADVANCED PROGRAMMING PRACTICE
MULTIPLE PROGRAMMING PARADIGMS
• Multiple programming paradigms, also known as multi-paradigm programming, refers to
the ability of a programming language to support and integrate multiple programming
styles or paradigms within a single language. A programming paradigm is a way of
thinking and structuring programs based on certain principles and concepts.
• Traditionally, programming languages have been associated with a specific paradigm,
such as procedural, object-oriented, or functional. However, with the advancement of
programming language design, many modern languages have incorporated elements and
features from multiple paradigms, providing developers with more flexibility and
expressive power.
DEPT. OF CSE, SRMIST
20
21CSC203P - ADVANCED PROGRAMMING PRACTICE
MULTIPLE PROGRAMMING PARADIGMS
• Procedural Programming: This paradigm focuses on the step-by-step execution of a
sequence of instructions or procedures. It emphasizes the use of procedures or functions
to organize and structure code. Example C
• Object-Oriented Programming (OOP): OOP is based on the concept of objects that
encapsulate data and behavior. It promotes modularity, reusability, and data abstraction.
Languages like C++, Java, and Python support OOP.
• Functional Programming: This paradigm treats computation as the evaluation of
mathematical functions. It emphasizes immutability, pure functions, and higher-order
functions. Languages like Haskell, Lisp, and Scala support functional programming.
DEPT. OF CSE, SRMIST
21
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• Declarative Programming: Declarative programming focuses on describing the desired result
rather than specifying the detailed steps to achieve it. Examples include SQL for database queries
and HTML/CSS for web development.
• Logic Programming: Logic programming involves defining relationships and rules and letting the
program reason about queries and logical inferences. Prolog is a popular logic programming
language.
• Concurrent Programming: Concurrent programming deals with handling multiple tasks or
processes that execute concurrently or in parallel. Languages like Go and Erlang provide built-in
support for concurrency.
• By supporting multiple paradigms, programming languages can address different problem domains and
allow developers to choose the most appropriate style for a given task. This flexibility enables the
combination of different programming techniques within a single program, leading to more expressive and
maintainable code. It also promotes code reuse and interoperability between different paradigms, as
developers can leverage the strengths of each paradigm to solve specific challenges
DEPT. OF CSE, SRMIST
22
21CSC203P - ADVANCED PROGRAMMING PRACTICE
PROGRAMMING PARADIGM HIERARCHY
• The concept of a programming paradigm hierarchy refers to the organization and
relationship
between
different
programming
paradigms
based
on
their
characteristics and capabilities. It provides a way to understand how various
paradigms relate to each other and how they build upon or differ from one another
in terms of abstraction, data handling, control flow, and programming concepts.
• While there is no universally accepted hierarchy, here is a general representation of
the programming paradigm hierarchy:
DEPT. OF CSE, SRMIST
23
21CSC203P - ADVANCED PROGRAMMING PRACTICE
PROGRAMMING PARADIGM HIERARCHY
• Imperative Programming: Imperative programming is considered the foundational
paradigm and encompasses procedural programming. It focuses on specifying a
sequence of instructions that the computer must execute to achieve a desired
outcome. It involves mutable state and explicit control flow. Procedural
programming, such as C, Pascal, and Fortran, falls within this category.
• Structured Programming: Structured programming builds upon imperative
programming and emphasizes the use of structured control flow constructs like
loops and conditionals. It aims to improve code readability and maintainability by
using procedures, functions, and modules for organizing and structuring code.
Languages like C, Pascal, and Python support structured programming.
DEPT. OF CSE, SRMIST
24
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• Object-Oriented Programming (OOP): Object-oriented programming introduces
the concept of objects that encapsulate data and behavior. It focuses on data
abstraction, encapsulation, inheritance, and polymorphism. OOP allows for modular
and reusable code and supports concepts like classes, objects, and inheritance.
Languages like Java, C++, and Python support OOP.
• Functional Programming: Functional programming treats computation as the
evaluation of mathematical functions. It emphasizes immutability, pure functions,
higher-order functions, and declarative programming. Functional programming
avoids mutable state and emphasizes data transformations. Languages like Haskell,
Lisp, and Scala support functional programming.
DEPT. OF CSE, SRMIST
25
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• Logic Programming: Logic programming focuses on defining relationships and
rules using logical formulas. It uses logical inference to query and reason about
these relationships. Prolog is a popular logic programming language.
• Concurrent Programming: Concurrent programming deals with handling multiple
tasks or processes that execute concurrently or in parallel. It addresses
synchronization, communication, and coordination among concurrent processes.
Languages like Go, Erlang, and Java (with concurrency libraries) provide support for
concurrent programming.
DEPT. OF CSE, SRMIST
26
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• Imperative Paradigm: Procedural, Object-Oriented and Parallel processing
• The imperative paradigm is a programming paradigm that focuses on specifying a sequence of
instructions or statements that the computer must execute to achieve a desired outcome. It involves
describing the steps or procedures to be followed in order to solve a problem.The imperative
paradigm is characterized by mutable state and explicit control flow.
Procedural Programming : Procedural programming is a specific form of the imperative paradigm that
organizes code into procedures or subroutines. It emphasizes the use of procedures or functions,
which are named blocks of code that can be called and executed from different parts of the program.
Procedural programming promotes code modularity, reusability, and structured control flow using
constructs like loops and conditionals. Languages like C, Pascal, and Fortran are examples of
procedural programming languages.
DEPT. OF CSE, SRMIST
27
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Object-Oriented Programming (OOP):
• OOP extends the imperative paradigm by introducing the concept of objects. In
OOP, objects are entities that encapsulate data (attributes) and behavior (methods
or functions). OOP emphasizes concepts such as data abstraction, encapsulation,
inheritance, and polymorphism. It allows for modular and reusable code through the
use of classes, which define the blueprint for creating objects. Languages like Java,
C++, and Python are examples of languages that support object-oriented
programming.
DEPT. OF CSE, SRMIST
28
21CSC203P - ADVANCED PROGRAMMING PRACTICE
PARALLEL PROCESSING
• Parallel processing is a concept that refers to the simultaneous execution of multiple tasks or processes.
It involves dividing a problem into smaller subproblems that can be executed concurrently on multiple
processors or cores. The goal of parallel processing is to improve performance and efficiency by
exploiting the available computational resources.
• Parallel processing can be achieved through various techniques, such as multi-threading,
multiprocessing, and distributed computing. Languages like Go, Erlang, and Java (with concurrency
libraries) provide support for parallel processing.
• In summary, the imperative paradigm focuses on specifying a sequence of instructions to be executed
by the computer. Procedural programming organizes code into procedures or subroutines, while objectoriented programming introduces the concept of objects for data encapsulation and modular code.
• Parallel processing allows for the simultaneous execution of multiple tasks or processes to improve
performance. These concepts and paradigms provide different approaches and techniques for
structuring and solving problems within the imperative programming paradigm
DEPT. OF CSE, SRMIST
29
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Declarative programming paradigm: Logic, Functional and Database processing
• Declarative programming is a programming paradigm that focuses on describing what needs to be achieved
rather than how to achieve it.
• It emphasizes the use of declarative statements or expressions that specify the desired result or outcome,
leaving the details of how the computation is carried out to the underlying system or interpreter.
• Declarative programming consists of several sub-paradigms, including logic programming, functional
programming, and database processing:
Logic Programming:
• Logic programming is a declarative programming paradigm that is based on formal logic. It involves defining
relationships, rules, and constraints using logical formulas.
• The programmer specifies a set of logical rules, and the program uses logical inference to query and reason
about these rules.
• The most well-known logic programming language is Prolog, which provides mechanisms for defining relations
and conducting logical queries.
DEPT. OF CSE, SRMIST
30
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Functional Programming:
• Functional programming is another declarative programming paradigm that treats
computation as the evaluation of mathematical functions.
• It emphasizes the use of pure functions, which have no side effects and always
produce the same output for the same input.
• Functional programming promotes immutability, higher-order functions, and the
composition of functions to achieve desired results. Languages like Haskell, Lisp,
and Scala support functional programming.
DEPT. OF CSE, SRMIST
31
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Database Processing :
• Database processing is a specific application of declarative programming that
deals with manipulating and querying databases.
• SQL (Structured Query Language) is a common language used in database
processing, which allows programmers to declaratively specify operations like
querying, inserting, updating, and deleting data from databases.
• In SQL, the programmer describes the desired results and lets the database
management system (DBMS) handle the optimization and execution details.
DEPT. OF CSE, SRMIST
32
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• In all of these declarative programming sub-paradigms, the focus is on expressing the desired
outcome or relationship rather than specifying a step-by-step procedure.
• The systems or interpreters responsible for executing declarative programs handle the details of
how to achieve the desired result efficiently.
• Declarative programming allows for concise and expressive code, code reuse, and a higher
level of abstraction, making programs more maintainable and easier to reason about.
• However, it may have performance implications, as the underlying system must determine the
most efficient way to execute the declarative statements or queries
DEPT. OF CSE, SRMIST
33
21CSC203P - ADVANCED PROGRAMMING PRACTICE
MACHINE CODES – PROCEDURAL AND OBJECT ORIENTED
PROGRAMMING
• Machine code, also known as machine language, is the lowest level of
programming language that can be directly executed by a computer's processor.
• It consists of binary instructions that represent specific operations and data
manipulations understood by the computer's hardware.
• Machine code instructions are specific to a particular computer architecture or
processor.
DEPT. OF CSE, SRMIST
34
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Procedural Programming with Machine Code :
• In procedural programming, machine code instructions are used to write programs that follow a
procedural structure.
• Procedural programming focuses on breaking down a problem into a series of procedures or
functions, which are then executed sequentially. Each procedure or function contains a set of
machine code instructions that perform a specific task.
• In procedural programming with machine code, the programmer directly writes or manipulates the
machine code instructions to implement the desired functionality.
• The programmer needs to understand the low-level details of the computer's architecture, instruction
set, and memory layout to write efficient and correct code.
DEPT. OF CSE, SRMIST
35
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Object-Oriented Programming with Machine Code :
• Object-oriented programming (OOP) is a higher-level programming paradigm that emphasizes objects as the
fundamental building blocks of programs.
• OOP provides concepts such as classes, objects, encapsulation, inheritance, and polymorphism. While
machine code is not inherently object-oriented, it can still be used to implement object-oriented programming
principles at a lower level.
• In an object-oriented programming approach with machine code, the programmer can design and implement
their own object-oriented system using machine code instructions.
• This involves designing memory layouts, defining structures for objects, implementing inheritance and
polymorphism mechanisms manually, and managing method dispatching.
•
However, implementing object-oriented programming directly with machine code can be complex and errorprone, as it requires handling memory management, vtables, and other low-level details manually.
• This approach is rarely used in practice due to the availability of high-level programming languages and
compilers that abstract away these low-level details.
DEPT. OF CSE, SRMIST
36
21CSC203P - ADVANCED PROGRAMMING PRACTICE
SUITABILITY OF MULTIPLE PARADIGMS IN THE PROGRAMMING
LANGUAGE
• The suitability of multiple paradigms in a programming language refers to the extent to which the language
supports and integrates different programming paradigms effectively.
• It assesses how well a programming language accommodates the principles and concepts of various paradigms
and allows developers to seamlessly use multiple paradigms within a single codebase. The suitability of multiple
paradigms can have several advantages:
Flexibility and Expressiveness:
• Supporting multiple paradigms provides developers with a wider range of tools and techniques to solve
problems.
• Different paradigms excel in different problem domains, and having multiple paradigms at their disposal allows
developers to choose the most suitable approach for a given task. This flexibility and expressiveness enable
developers to write concise and efficient code.
DEPT. OF CSE, SRMIST
37
21CSC203P - ADVANCED PROGRAMMING PRACTICE
SUITABILITY OF MULTIPLE PARADIGMS IN THE PROGRAMMING
LANGUAGE
Code Reusability and Interoperability:
• Multiple paradigms often have their own libraries, frameworks, and ecosystems.
• By supporting multiple paradigms, a programming language allows developers to leverage existing
code and libraries from different paradigms.
• This promotes code reusability and interoperability, enabling developers to integrate different
components and systems seamlessly.
Problem-Specific Solutions:
• Some paradigms are better suited for specific problem domains.
• For example, functional programming is well-suited for mathematical calculations and data
transformations, while object-oriented programming is effective for modeling complex systems.
• By supporting multiple paradigms, a programming language enables developers to use the most
appropriate paradigm for a given problem, leading to more efficient and maintainable solutions.
DEPT. OF CSE, SRMIST
38
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Learning and Transition:
• Supporting multiple paradigms in a programming language benefits developers by allowing them to
learn and practice different programming styles. It broadens their skill set and enhances their
understanding of different programming concepts.
• Additionally, having multiple paradigms within a language makes it easier for developers to
transition between projects or teams that use different paradigms.
• Language Evolution and Innovation:
• The ability to incorporate multiple paradigms in a programming language facilitates language
evolution and innovation.
• By adopting concepts and ideas from different paradigms, a language can evolve to meet the
changing needs of the developer community and support emerging trends in software development.
DEPT. OF CSE, SRMIST
39
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• However, it's important to note that incorporating multiple paradigms in a programming language can
also introduce complexity.
• Developers need to carefully consider the trade-offs and design decisions associated with supporting
multiple paradigms.
• Striking a balance between providing flexibility and maintaining language consistency can be a
challenge.
• Overall, the suitability of multiple paradigms in a programming language provides developers with
flexibility, expressiveness, code reusability, and the ability to choose the most appropriate approach
for solving different problems.
• It empowers developers to write efficient and maintainable code and encourages innovation and
growth within the programming community
DEPT. OF CSE, SRMIST
40
21CSC203P - ADVANCED PROGRAMMING PRACTICE
SUBROUTINE
• A subroutine is a named sequence of instructions within a program that performs a
specific task. It is also known as a function or procedure. Subroutines help in
organizing code, promoting code reusability, and improving code readability.
• When a subroutine is called, the program jumps to the subroutine's location,
executes its instructions, and returns to the point of the program from where it was
called.
DEPT. OF CSE, SRMIST
41
21CSC203P - ADVANCED PROGRAMMING PRACTICE
SUBROUTINE
Method Call Overhead:
• Method call overhead refers to the additional time and resources required to invoke
a method or function in an object-oriented programming language. When a method
is called, there is a certain amount of overhead involved in setting up the call,
passing arguments, and returning results.
• This overhead includes tasks such as pushing arguments onto the stack, saving
registers, and managing the call stack. While the overhead is typically small and
negligible for most applications, it becomes more significant in high-performance
scenarios or when calling methods frequently in tight loops.
DEPT. OF CSE, SRMIST
42
21CSC203P - ADVANCED PROGRAMMING PRACTICE
DYNAMIC MEMORY ALLOCATION FOR MESSAGE AND OBJECT STORAGE
• In object-oriented programming, objects are instances of classes that encapsulate data and
behavior.
• Dynamic memory allocation is often used to allocate memory for objects during runtime.
• When an object is created, memory is dynamically allocated from the heap to store the object's data.
• This dynamic memory allocation allows objects to have a flexible lifetime and enables the creation
and destruction of objects as needed.
• Message passing is a mechanism used in object-oriented programming to invoke methods or
communicate between objects.
• When a message is sent to an object, the object's method is invoked to handle the message.
• Depending on the programming language and implementation, the message might contain
information such as the name of the method and the arguments to be passed.
DEPT. OF CSE, SRMIST
43
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• Dynamic memory allocation for message and object storage involves the allocation and deallocation
of memory during runtime, as objects are created, used, and destroyed.
• This flexibility in memory allocation allows for dynamic object creation, polymorphism, and memory
management.
• However, dynamic memory allocation comes with additional overhead compared to static memory
allocation. There is a cost associated with allocating and deallocating memory, and improper memory
management can lead to memory leaks or fragmentation.
• Efficient memory allocation strategies and techniques, such as pooling, garbage collection, or smart
pointers, are often employed to optimize memory usage and minimize overhead in dynamic memory
allocation scenarios.
• Overall, subroutines, method call overhead, and dynamic memory allocation for message and object
storage are important concepts in programming that help organize code, enable code reuse, and
provide flexibility in memory management.
• Understanding these concepts is crucial for writing efficient and maintainable code in procedural and
object-oriented programming paradigms.
DEPT. OF CSE, SRMIST
44
21CSC203P - ADVANCED PROGRAMMING PRACTICE
DYNAMICALLY DISPATCHED MESSAGE CALLS AND DIRECT PROCEDURE CALL
OVERHEADS
Dynamically Dispatched Message Calls:
• In object-oriented programming, dynamically dispatched message calls refer to the
mechanism of invoking methods or functions on objects at runtime based on the actual type
of the object.
• When a message is sent to an object, the runtime system determines the appropriate
method to be called based on the object's dynamic type or class hierarchy.
• Dynamically dispatched message calls involve a level of indirection and typically incur some
overhead compared to direct procedure calls. The overhead is due to the need for runtime
lookup and method resolution to determine the correct method implementation to be
invoked.
DEPT. OF CSE, SRMIST
45
21CSC203P - ADVANCED PROGRAMMING PRACTICE
DYNAMICALLY DISPATCHED MESSAGE CALLS AND DIRECT
PROCEDURE CALL OVERHEADS
• This lookup process involves traversing the object's class hierarchy and finding the appropriate
method implementation based on the dynamic type of the object.
• The overhead associated with dynamically dispatched message calls can vary depending on factors
such as the programming language, the complexity of the class hierarchy, and the efficiency of the
runtime system.
• However, modern object-oriented programming languages and runtime systems employ various
optimizations, such as caching method tables or using virtual function tables (vtables), to reduce the
overhead of dynamic dispatch.
DEPT. OF CSE, SRMIST
46
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Direct Procedure Call Overheads:
• Direct procedure calls refer to the direct invocation of procedures or functions without involving any
dynamic dispatch mechanism.
• In direct procedure calls, the address of the function is known at compile time, allowing the program to
directly jump to the memory location of the function and execute its instructions.
• Direct procedure calls typically have lower overhead compared to dynamically dispatched message
calls.
• The direct nature of the call avoids the need for runtime method resolution and lookup, reducing the
indirection and associated overhead.
• Direct procedure calls have a more straightforward and efficient execution path since the target
procedure's address is known in advance.
DEPT. OF CSE, SRMIST
47
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• However, it's important to note that the overhead of direct procedure calls can still exist due
to factors such as argument passing, stack manipulation, and context switching.
• The specific overhead may vary depending on the programming language, the calling
convention used, and the underlying hardware architecture.
• In general, dynamically dispatched message calls introduce a level of indirection and
overhead due to the runtime lookup and method resolution required.
• On the other hand, direct procedure calls have lower overhead as they directly invoke
functions without the need for runtime lookup.
• The choice between dynamically dispatched message calls and direct procedure calls
depends on the specific requirements of the application, the level of polymorphism needed,
and the performance considerations.
DEPT. OF CSE, SRMIST
48
21CSC203P - ADVANCED PROGRAMMING PRACTICE
OBJECT SERIALIZATION
• Object serialization refers to the process of converting an object's state into a format
that can be stored, transmitted, or reconstructed later.
• It involves transforming the object and its associated data into a sequence of bytes,
which can be written to a file, sent over a network, or stored in a database.
• The reverse process, where the serialized data is used to reconstruct the object, is
called deserialization.
DEPT. OF CSE, SRMIST
49
21CSC203P - ADVANCED PROGRAMMING PRACTICE
OBJECT SERIALIZATION
Object serialization is primarily used for two purposes:
• Persistence: Object serialization allows objects to be stored persistently, meaning they
can be saved to a file or database and retrieved later. This enables applications to preserve
the state of objects across multiple program executions or to transfer objects between
different systems.
• Communication: Serialized objects can be sent over a network or transferred between different
processes or systems. This is particularly useful in distributed systems or client-server architectures
where objects need to be exchanged between different components or across different platforms.
• During object serialization, the object's state, which includes its instance variables, is transformed
into a serialized form. This process may involve encoding the object's data, along with information
about its class structure and metadata. The serialized data is typically represented as a sequence of
bytes or a structured format like XML or JSON.
DEPT. OF CSE, SRMIST
50
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• Some programming languages and frameworks provide built-in support for object serialization,
offering libraries and APIs that handle the serialization and deserialization process automatically.
These libraries often provide mechanisms to control serialization, such as excluding certain fields,
customizing serialization behavior, or implementing custom serialization logic.
• However, not all objects are serializable by default. Certain object attributes, such as open file
handles, network connections, or transient data, may not be suitable for serialization. In such cases,
specific measures need to be taken to handle or exclude these attributes during serialization.
• Object serialization is a powerful mechanism that facilitates data storage, communication, and
distributed computing. It allows objects to be easily persisted or transmitted across different systems,
preserving their state and enabling seamless integration between heterogeneous environments
DEPT. OF CSE, SRMIST
51
21CSC203P - ADVANCED PROGRAMMING PRACTICE
PARALLEL COMPUTING
• Parallel computing refers to the use of multiple processors or computing resources to solve a
computational problem or perform a task simultaneously.
• It involves breaking down a problem into smaller parts that can be solved concurrently or in parallel,
thus achieving faster execution and increased computational power.
• Parallel computing can be applied to various types of problems, ranging from computationally
intensive scientific simulations and data analysis to web servers handling multiple requests
simultaneously.
• It is particularly beneficial for tasks that can be divided into independent subtasks that can be
executed concurrently.
DEPT. OF CSE, SRMIST
52
21CSC203P - ADVANCED PROGRAMMING PRACTICE
PARALLEL COMPUTING
•
There are different models and approaches to parallel computing:
Task Parallelism:
• In task parallelism, the problem is divided into multiple independent tasks or subtasks that can be executed
concurrently.
• Each task is assigned to a separate processing unit or thread, allowing multiple tasks to be processed
simultaneously.
• Task parallelism is well-suited for irregular or dynamic problems where the execution time of each task may vary.
Data Parallelism :
• Data parallelism involves dividing the data into smaller chunks and processing them simultaneously on different
processing units.
• Each unit operates on its portion of the data, typically applying the same computation or algorithm to each
chunk.
• Data parallelism is commonly used in scientific simulations, image processing, and numerical computations.
DEPT. OF CSE, SRMIST
53
21CSC203P - ADVANCED PROGRAMMING PRACTICE
Message Passing:
• Message passing involves dividing the problem into smaller tasks that communicate and exchange
data by sending messages to each other.
• Each task operates independently and exchanges information with other tasks as needed.
• This approach is commonly used in distributed systems and parallel computing frameworks such as
MPI (Message Passing Interface).
Shared Memory:
• Shared memory parallelism involves multiple processors or threads accessing and modifying a
shared memory space.
• This model allows parallel tasks to communicate and synchronize by reading and writing to shared
memory locations.
• Programming models such as OpenMP and Pthreads utilize shared memory parallelism.
DEPT. OF CSE, SRMIST
54
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• Parallel computing offers several benefits, including:
Increased speed:
• By dividing the problem into smaller parts and executing them simultaneously, parallel computing
can significantly reduce the overall execution time and achieve faster results.
Enhanced scalability:
• Parallel computing allows for the efficient utilization of multiple processing units or resources,
enabling systems to scale and handle larger workloads.
Improved performance:
• Parallel computing enables the execution of complex computations and simulations that would
otherwise be infeasible or take an impractical amount of time with sequential processing.
DEPT. OF CSE, SRMIST
55
21CSC203P - ADVANCED PROGRAMMING PRACTICE
• However, parallel computing also introduces challenges such as load balancing, data
synchronization, and communication overhead.
• Proper design and optimization techniques are essential to ensure efficient and effective parallel
execution.
• Overall, parallel computing is a powerful approach for achieving high-performance computing and
tackling complex problems by harnessing the capabilities of multiple processing units or resources.
• It plays a crucial role in various domains, including scientific research, data analysis, artificial
intelligence, and large-scale computing systems
DEPT. OF CSE, SRMIST
56
21CSC203P - ADVANCED PROGRAMMING PRACTICE
THANK YOU
DEPT. OF CSE, SRMIST
57
21CSC203P - ADVANCED PROGRAMMING PRACTICE
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )