Programming Language Paradigms

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following best describes a programming paradigm?

  • The process of translating source code into machine code.
  • A specific set of tools used for software development.
  • A way (or) style of thinking to solve a problem. (correct)
  • The hardware architecture on which software is run.

Why is it beneficial for a programmer to understand multiple programming paradigms?

  • It allows them to write code that runs faster on specific operating systems.
  • It reduces the amount of code needed to solve any given problem.
  • It guarantees that the programmer will always use the most efficient algorithm.
  • Different problems are better suited to different styles of approach. (correct)

In which programming paradigm is the programmer most concerned with instructing the computer on how to solve a task?

  • Logical.
  • Functional.
  • Declarative.
  • Imperative. (correct)

Which programming paradigm focuses on defining what result is desired, rather than how to achieve it?

<p>Declarative. (A)</p> Signup and view all the answers

Which of the following paradigms treats data and procedures as distinct entities?

<p>Procedural paradigm. (C)</p> Signup and view all the answers

Which feature is a characteristic of the Procedural Programming Paradigm?

<p>Linear top-down approach. (B)</p> Signup and view all the answers

In the context of Procedural Programming, what is the significance of 'events'?

<p>Events trigger procedures in a non-linear fashion, contrasting with the paradigm's typical approach. (D)</p> Signup and view all the answers

Which of the following is an example of a procedural programming language?

<p>C. (C)</p> Signup and view all the answers

In the context of parallel computing, what characterizes the execution of processes?

<p>Simultaneous execution. (B)</p> Signup and view all the answers

Which of the following describes a key advantage of parallel computing?

<p>Provides concurrency and saves time and money. (C)</p> Signup and view all the answers

Which factor can be a limitation of parallel computing?

<p>Communication and synchronization between multiple sub-tasks. (B)</p> Signup and view all the answers

In what area is parallel computing commonly applied?

<p>Advanced graphics, augmented reality and virtual reality. (D)</p> Signup and view all the answers

What is a fundamental characteristic of object-oriented programming (OOP)?

<p>Organization around objects, grouped in classes. (B)</p> Signup and view all the answers

Which of the following is a key feature of object-oriented programming?

<p>Bottom-up approach in program design. (D)</p> Signup and view all the answers

Which concept is NOT a basic component of Object Oriented Programming?

<p>Modularity. (C)</p> Signup and view all the answers

What best describes a 'class' in object-oriented programming?

<p>A blueprint describing the nature of something. (D)</p> Signup and view all the answers

What is the primary role of 'attributes' in object-oriented programming?

<p>To store the state of an object. (B)</p> Signup and view all the answers

How does 'inheritance' contribute to code reusability in object-oriented programming?

<p>By creating new collections of attributes and behaviours based on previously defined classes. (D)</p> Signup and view all the answers

What is the purpose of 'abstraction' in object-oriented design?

<p>To model classes appropriate to the problem, simplifying a complex reality. (B)</p> Signup and view all the answers

What does 'encapsulation' achieve in object-oriented programming?

<p>It bundles data members and member functions, choosing which members to expose or hide. (C)</p> Signup and view all the answers

What is 'polymorphism' in the context of object-oriented programming?

<p>The ability of a message to be displayed in more than one form. (D)</p> Signup and view all the answers

Which of the following is a characteristic of the Logic Programming paradigm?

<p>Expressing facts and rules about a problem within a system of formal logic. (D)</p> Signup and view all the answers

What is a key advantage of logic-oriented programming?

<p>The system solves the problem, keeping programming steps to a minimum. (B)</p> Signup and view all the answers

Which language is most closely associated with the Logic Paradigm?

<p>Prolog. (B)</p> Signup and view all the answers

In the Functional Paradigm, what is the primary means of computation?

<p>Execution of series of mathematical functions. (B)</p> Signup and view all the answers

How does the Functional Paradigm handle data modification?

<p>Data is treated as immutable; functions return new values instead of modifying existing ones. (D)</p> Signup and view all the answers

What is a potential disadvantage of the Functional Paradigm?

<p>Recursion can lead to decrease in performance. (C)</p> Signup and view all the answers

Which language does NOT support the Functional Paradigm?

<p>C++. (D)</p> Signup and view all the answers

What characterizes the Database/Data-Driven programming approach?

<p>It is primarily on data and its movement. (A)</p> Signup and view all the answers

What role does a database program play in a business information system?

<p>Serves as is the heart of business information, providing file creation, data entry, query and reporting functions. (D)</p> Signup and view all the answers

What is a key requirement of functionality in the Database Paradigm?

<p>Knowledge of the abstract data type of the variables it is working with. (B)</p> Signup and view all the answers

Which of the following languages does NOT support a data-driven paradigm?

<p>FORTRAN. (C)</p> Signup and view all the answers

What is a potential disadvantage of the Database Paradigm?

<p>Potential for bad object-oriented programming from abstract data type (C)</p> Signup and view all the answers

Which choice best describes a key goal of Aspect-Oriented Programming (AOP)?

<p>Provide separation of concerns, facilitating several cross-cutting concerns. (D)</p> Signup and view all the answers

Which of the following describes how the AOP paradigm relates to OOP?

<p>AOP is complementary to OOP. (C)</p> Signup and view all the answers

What mechanism in AOP weaves the aspects and the core modules of a program together?

<p>Aspect weaver. (D)</p> Signup and view all the answers

In AOP, what does a 'join point' represent?

<p>A location in the code where an aspect can be applied. (C)</p> Signup and view all the answers

In AOP, what is the purpose of 'advice'?

<p>To define an action taken by an aspect at a particular join point. (C)</p> Signup and view all the answers

Which paradigms relies on flows determined by external events?

<p>Event-driven programming paradigm. (A)</p> Signup and view all the answers

Which of the following languages is most closely associated with being event driven?

<p>Visual Basic. (B)</p> Signup and view all the answers

In Event-Driven Programming, what role does the 'scheduler' play?

<p>It determines the event type and calls the appropriate event handler. (C)</p> Signup and view all the answers

In event-driven programming, why is the order of execution not always clear?

<p>Because events can occur non-deterministically. (C)</p> Signup and view all the answers

What is the purpose of an 'event queue' in event-driven programming?

<p>To handle events as they front of the procedure. (C)</p> Signup and view all the answers

In Imperative Programming, which is emphasized?

<p>Telling the computer 'HOW' to do something. (C)</p> Signup and view all the answers

Which of the following is an example of abstraction in the Declarative Paradigm?

<p>Using map or filter functions over arrays. (D)</p> Signup and view all the answers

Flashcards

What is a Paradigm?

A way, or style, of thinking to solve a problem.

What is a Programming Language Paradigm?

A way a computer language views a problem to be solved.

What is Imperative Programming?

A programming style where you instruct the computer in a step-by-step process on how to solve a task.

What is Declarative Programming?

A programming style focused on WHAT the desired result is, not HOW to get it.

Signup and view all the flashcards

What is Procedural Programming?

Instructions are written step-by-step to get the final result.

Signup and view all the flashcards

What is Parallel Computing?

A computational method where many calculations are carried out simultaneously.

Signup and view all the flashcards

What is Object-Oriented Programming (OOP)?

A programming model organized around objects, which contain data and methods.

Signup and view all the flashcards

What is a Class in OOP?

An abstract data type; a blueprint describing the nature of something.

Signup and view all the flashcards

What is an Object in OOP?

An individual instance of a class, created at runtime.

Signup and view all the flashcards

What are Attributes in OOP?

Data members or variables encapsulated within a class or object.

Signup and view all the flashcards

What is Inheritance in OOP?

New classes inherit attributes and behaviors from existing classes.

Signup and view all the flashcards

What is Abstraction in OOP?

Simplifying complex reality by modeling classes appropriate to the problem.

Signup and view all the flashcards

What is Encapsulation?

Bundling of data members and member functions within a class.

Signup and view all the flashcards

What is Polymorphism?

The ability of a message to be displayed in more than one form.

Signup and view all the flashcards

What is Logic Paradigm?

Statements express facts/rules within a system of formal logic.

Signup and view all the flashcards

What is the Functional Paradigm?

Execution of a series of mathematical functions.

Signup and view all the flashcards

What is Database/Data-Driven Programming?

Database programming based on data and its movement.

Signup and view all the flashcards

What is Aspect Oriented Programming?

Modularizes code into processes instead of focusing on objects.

Signup and view all the flashcards

What is Event-Driven Programming?

Flow determined by events; designed to detect events as they occur.

Signup and view all the flashcards

What are Aspects in AOP?

Part of the application which cross-cuts the core concerns.

Signup and view all the flashcards

What is a Join Point in AOP?

A location where an aspect can be applied.

Signup and view all the flashcards

What is Advice in AOP?

Behavior triggered by a specific join point.

Signup and view all the flashcards

What are Pointcuts?

Determines when advice should be applied.

Signup and view all the flashcards

Study Notes

Programming Language Paradigms

  • A programming language paradigm is the approach a language takes to solve problems.

What is Paradigm?

  • A paradigm is a style or method of thinking to solve a problem.

What is Programming Language Paradigm?

  • A programming language paradigm is how a computer language addresses problem-solving.

Types of Programming Language Paradigms

  • Imperative and declarative programming are the two main paradigms.
  • Imperative paradigms include procedural, object-oriented, and parallel processing.
  • Declarative paradigms include logic, functional, and database.

Why So Many Paradigms?

  • Using different paradigms aids in the facilitation of different styles of approach to meet the requirements of various problems.
  • Some problems need mathematical models and clear flow, others just need a straightforward solution.

Which to Learn First?

  • It is important to learn the paradigm of a subject before diving into the language itself.
  • This enables coding that aligns with the compiler's assumed control flow, leading to optimized coding.

Imperative Paradigm

  • Focuses on the "how" of solving a task through a step-by-step process.
  • Programming involves instructing the computer in a specific manner to achieve a task.

Declarative Programming Paradigm

  • Focuses on "what" the desired result is, rather than detailing the steps.

  • Code focuses on building the logic of the software without detailing flow.

  • HTML, XML, CSS, SQL, Prolog, Haskell, F#, and Lisp are languages that fall under the declarative paradigm.

  • Programs often compile to efficient binary executables.

  • Statements are grouped into sections using blocks for simplicity.

  • C, C++, C#, and Java are imperative languages.

Procedural Programming Paradigm

  • Writing instructions step-by-step to get the final result.

  • A process that directly instructs a device to execute logical steps to finish a task.

  • Approached in a linear, top-down manner.

  • Data and procedures are treated as separate entities.

  • Programs are divided into procedures/routines/functions which each contain a series of steps.

  • Languages derived in third-generations.

  • Contrasted with event-driven programming.

  • Procedures are called/executed only in response to events.

  • Events are unpredictable.

  • Procedures to handle unpredictable events cannot be executed linearly.

Key Features of Procedural Programming

  • Utilizes predefined functions, local and global variables, modularity, and parameter passing.

Procedural Programming Languages

  • Common Business Oriented Language (COBOL)
  • Formula Translation (FORTRAN)
  • Algorithmic Language (ALGOL)
  • Programming Language One (PL/I)
  • Beginners All-purpose Symbolic Instruction Code (BASIC)
  • C

Parallel Computing

  • Computation where calculations or processes are executed simultaneously.
  • Problem-solving using multiple processing elements at the same time.
  • Problems are broken down into instructions solved concurrently by multiple resources.
  • An example of parallel computing can be illustrated by a scenario where two cashiers give movie tickets to people waiting in two queues at the same time.

Why Parallel Computing?

  • It is useful for real-world, dynamic simulations.
  • Offers time and money savings by providing concurrency.
  • Effectively manages complex, large datasets.
  • Ensures effective utilization of resources and hardware.
  • It is impractical to implement real-time systems using serial computing.

Limitations of Parallel Computing

  • Communication and synchronization between multiple sub-tasks is difficult.
  • Algorithms need proper managing that can be handled in a parallel mechanism.
  • Algorithms/programs must have low coupling and high cohesion, which is difficult to achieve.
  • Requires skilled and expert programmers.

Applications of Parallel Computing

  • Used in databases, data mining, real-time simulations, science, engineering, advanced graphics, augmented reality, and virtual reality.

Object-Oriented Programming

  • Based on objects containing data and methods.
  • Aims to incorporate advantages of modularity and reusability.
  • Object-instances of classes interact with each other.
  • Examples of languages: C++, Java, Python, Ruby.

Important Features of Object-Oriented Programming

  • Bottom-up approach in program design.
  • Programs are organized around objects grouped into classes.
  • Centers on data with methods for object operations.
  • Enables interaction between objects through functions.
  • Provides design reusability through new classes that add to existing classes

Basic Concepts of Object-Oriented Programming

  • Includes classes, objects, attributes, methods, inheritance, abstraction, encapsulation, information hiding, and polymorphism.

Class

  • An abstract data type and a blueprint describing the nature of something.
  • A data structure may contain different fields.
  • An object defined to contain procedures that act on it.
  • Attributes / fields are like data.
  • Operations / methods are like functions.

Object

  • An individual instance of a class created at runtime.
  • The state of an object consists of values assigned to its attributes.
  • Behaviour is defined in the class.
  • Initialized by implicitly calling its constructor.
  • A member function is one of the methods an object has.

Attributes

  • Data members or member variables that are encapsulated within a class or object.
  • Variables are initialized using a constructor.
  • Represent the state of an object

Inheritance

  • Compartmentalizes code, making it reusable.
  • Based on collections of attributes and behaviors from previously defined classes.
  • Subclasses inherit attributes and behaviors from superclasses.
  • This relationship creates a hierarchy.
  • A single class can inherit from 2 classes that have members bearing the same names but different meanings.

Abstraction

  • Simplifying complex reality by modeling classes appropriately to the problem.
  • Object-oriented programming provides abstraction through composition and inheritance.
  • A Class Car, can be viewed as a composition of engine, gearbox, and steering.
  • When driving, there is no need to know how different components work internally.

Encapsulation and Information Hiding

  • Bundling of data members and member functions.
  • Choosing whether to expose or hide members of a class.
  • Achieved by specifying which classes may use the members.
  • Prevents unauthorized objects from changing the state of an object.

Polymorphism

  • "Poly" means many and "morph" means forms.
  • The ability of a message to be displayed in more than one form.
  • For example, a man as a Father, husband, and employee
  • The same person possesses different behaviors in different situations.
  • One interface, multiple implementations.

Types of Declarative Paradigm

  • Divided into Logic, Functional and Database paradigms

Logic Paradigm

  • Program statements express facts and rules within a formal logic system.
  • Divided into definitions, facts, and a declaration of aims as a request
  • Deducible answers to a query are returned, built entirely from relations.

Advantages of Logical Programming

  • The programming steps are minimal since the system solves the problem.
  • Demonstrating the rationality of a given program is easy.

Languages using Logic Paradigm

  • Datalog
  • ASP
  • Prolog

Functional Paradigm

  • The key principle is the execution of a series of mathematical functions.
  • Functions can be replaced with their values without changing the program's meaning.
  • Math operations are based on inputs, avoiding temporary variables to store results between inputs.

Advantage of Funtional Paradigm

  • The code is more readable and easily understandable.
  • Testing and debugging is easier.
  • Useful for pure function concurrency.
  • Values are stored only when needed.
  • Provides a protected environment with no side effects.

Disadvantage of Functional Paradigm

  • Recursion can decrease performance.
  • Functional programming can be less efficient than other styles.
  • Requires large amounts of time and memory.
  • Purely functional languages are not widely used in commercial software development.

Programming Language using Functional Paradigm

  • Haskell
  • JavaScript
  • Scala
  • Lisp
  • ML
  • Clojure
  • Common Lisp

Database/Data Driven Programming Approach

  • Database programming methodology based on data and its movement.
  • Program statements are defined by data.
  • Database programs are the heart of information systems, offering creation, entry, update, query, and reporting functions.

Database or Datadriven Programming Language

  • AWK
  • Oz
  • Perl
  • sed
  • Lua
  • Clojure

Advantages of Database Paradigm

  • Requires awareness of the abstract data type.
  • Functions and interfaces can be used on all objects with the same data field.
  • Data of objects/entities can be grouped without consequences.

Disadvantage of Database Paradigm

  • Dealing with abstract data types may lead to poor object-oriented programming.
  • Modifying object structures can break functions.

Minor Paradigms

  • Aspect-oriented programming
  • Event-driven programming

Aspect Oriented Programming

  • AOP is complementary to OOP.
  • AOP modularizes code into processes, while OOP modularizes into objects.
  • Provides separation of concern in code.
  • Facilitates cross-cutting concerns.
  • Adds behavior to code without modifying the code.

Need for AOP

  • Provides cross-cutting concerns and creates cleaner, reusable code.
  • The common purposes of usage can include security, transactions, and logging.
  • Increases code understanding and is applied using an aspect weaver.

Basic Terminologies of AOP

  • Aspects are parts of the application that cross-cut core concerns of objects.

  • Join points are behaviors like exception handling or method execution of objects.

  • Advice is an action taken by an aspect at a join point, either before or after its execution.

  • Pointcuts determine the join points where advice should be applied.

  • AOP enhances OOP.

  • AOP and OOP can be utilized at the same time.

  • Programs where the flow of execution is determined by events.

  • Designed to detect and handle them via Event Handling Procedures

  • Extension of interrupt-driven programming found in DOS, Embedded Systems

  • The majority of object-oriented and visual languages support event-driven programming, such as Visual Basic, Visual C++, and Java.

  • VB is specifically designed for event-driven approach and provides IDE.

  • VB provides much of the code for detecting events automatically that the programmer designs interface design and other event handling code

Background of Event Driven Programming

  • Before its evolution, procedural programs determined flow.

  • Modern event-driven programs have no discernible control flow.

  • Event loops wait for events and invoke appropriate routines.

  • Code for the event loop provided by event-development environment.

  • Change from procedural to event-driven is accelerated by the introduction of Graphical User Interface (GUI).

  • It emerged during the introduction of Object Oriented Programming in the late 1970s.

  • Software at the time had user interfaces and a set of event handling procedures to deal with queries and updates.

Working of Event Driven Programming

  • Scheduler determines the event type and calls the appropriate handler.

  • Centralized element of event applications.

  • Event handlers deal with specific occurrences using blocks of procedural code.

  • Causes a visual response and a state change of the system, that encompasses both data used and the user interface.

  • Leads to the invocation of a second event handler.

  • Event handlers can also discard series of events.

Event Queue

  • Series of events cannot be processed at the same time.
  • Events are handled by an Event Queue
  • Priority scheme enables fast tracking by the scheduler.
  • Queue length and processing time depend on processor speed, RAM, and simultaneously running applications.

Imperative vs Declarative Paradigm

Imperative Paradigm

  • Focuses on "how" to do something, detailing exactly how to achieve the result.
  • Provides more flexibility but sometimes involves complexity.
Var numbers=[1,2,3];
Var doubledNumbers= [];
for(var i=0;i<numbers.length;++i){
    doubledNumbers.push(numbers[i]*2);
}
console.log(doubledNumbers)

- -----&gt {2,4,6}
  • It is a strategy involved to use a condition for initialization to create a new array.

Declarative Paradigm

  • Expresses the logic of a computation without describing its control flow.
  • Provides simplicity and hides complexity.
Var Numbers=[1,2,3];
Var doubleNumbers= numbers.map (function(number)){
    return number *2;

console.log(doubledNumbers)--------&gt {2,4,6}
  • Map functions iterate over an array and push items into a new array before returning the computed array.
  • Increases the readability and compactness of the program.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

General Concepts on Programming Paradigms
10 questions
Programming Paradigms Overview
10 questions

Programming Paradigms Overview

IlluminatingNovaculite3231 avatar
IlluminatingNovaculite3231
Programming Paradigms Overview
8 questions

Programming Paradigms Overview

IlluminatingNovaculite3231 avatar
IlluminatingNovaculite3231
Use Quizgecko on...
Browser
Browser