lec1.pdf
Document Details
Uploaded by TantalizingAffection
Tags
Full Transcript
Farkhanda Zafar Raja Problem • • • • Every day, we come across different programming languages that we use for specific purposes. A problem can be solved in multiple ways using different programs. The approach we choose significantly affects the time and space complexity of the code, efficiency...
Farkhanda Zafar Raja Problem • • • • Every day, we come across different programming languages that we use for specific purposes. A problem can be solved in multiple ways using different programs. The approach we choose significantly affects the time and space complexity of the code, efficiency of development, and even the code’s readability for other programmers. Before getting deep into the subject, let’s understand what a programming paradigm means. What is a Programming Paradigm? • • • A programming paradigm represents the fundamental style or methodology of computer programming. Provides a conceptual framework for writing and structuring the code in a specific language. Provide different tools and strategies that can be used when solving problems, influencing factors such as the way tasks are divided, the nature of the data structures used, the types of operations that are implemented, and how tasks are coordinated. Each language has its own unique style and is often designed to favor a certain programming paradigm. However, many modern languages are multi-paradigm, meaning they incorporate features from several paradigms. Imperative Programming • Imperative programming is a programming paradigm that uses statements to change a program’s state. It’s concerned with describing how a program operates in a step-by-step manner 1. Procedural Programming This programming paradigm follows imperative programming with procedural calls. • These calls direct the system to perform the required tasks. • Each procedure, also known as a function, can have multiple commands to be executed. The function, once defined, can be called as many times as needed to perform the same operation. Languages: • • • • • C Fortran Pascal COBOL 2. Structured Programming • • It is an imperative programming paradigm where we use nested loops, conditional statements, and subroutines to define the control flow of a program. This paradigm has a top-down implementation which promotes code readability and reusability. Languages: • • • • • Algol 60 PL/I Pascal Ada 83 Modula 3. Object-Oriented Programming • • • • Most widely used and most popular programming paradigm. Class, Abstraction, Encapsulation, Inheritance, and Polymorphism form the backbone of Object-Oriented Programming (OOP). Every entity in the program is considered an object. Objects can have data associated with them called attributes and actions they can perform using methods. Languages??? Declarative Programming • • Declarative programming is a programming approach that expresses a computation’s logic without discussing its control flow. The programmer must specify what the program must accomplish but need not specify how it must be implemented. 1. Logic Programming • • • The logic programming paradigm uses logic-based statements to convey facts and rules. Logical inferences are made of instructions or logic statements to do computation. Atomic statements are built using these predicate statements. Languages • • • • Prolog Polka Vulcan Mercury 2. Functional Programming • • • Built upon the concept of mathematical functions and immutability. programs are constructed by applying and composing functions. This style of programming promotes a strong separation of data and behavior, and it is particularly useful when dealing with problems that involve concurrency and parallelism, due to its inherent properties such as referential transparency and absence of side-effects. More programming Paradigms Visual programming • • A type of programming paradigm where developers create computer programs by manipulating graphical elements and symbols rather than writing code using text-based programming languages. Make programming more accessible Here are some key characteristics and concepts related to visual programming: 1. Graphical Representation: In visual programming, the logic of a program is represented graphically using visual elements like icons, symbols, and blocks. These graphical elements are connected together to define the flow of the program. Drag-and-Drop Interface: Visual programming environments typically provide a drag-and-drop interface, allowing users to select and place elements on a canvas or workspace. Users can then connect these elements to create program logic. Flow-Based Programming: Many visual programming languages use a flow-based programming model, where the flow of data or control is represented by connecting blocks or nodes. This makes it easy to visualize how data and control move through the program. Event-Driven Programming: Visual programming environments are often used for event-driven programming, where actions are triggered by events (e.g., mouse clicks, button presses). Users can visually define how events are handled. Applications of Visual Programming?? Advantages • • • • • It is easier to learn than traditional coding, as visual programming uses graphical symbols and visual elements. It is easier to debug visual programs compared to text-based programming. It is faster and more efficient. It uses visual elements, which can help to remember instructions easier. It is visual so that it can create complex visual output such as graphs and visualizations. Disadvantages • • • • It is harder to access and modify the code of visual programming languages. It is not as flexible or powerful as traditional programming languages. It can be harder to debug visual programs than text-based ones because some visual objects can be hard to trace. Visual programming languages often require purchasing visual programming software, which may not be suitable for everyone.