0% found this document useful (0 votes)
14 views

Lec 8 Programming_Languages

Uploaded by

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

Lec 8 Programming_Languages

Uploaded by

Shahkaar Gul
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Programming Languages

History | Concepts | Paradigms


Instructor: Yasir Ali
History of Programming Languages
• - 1940s : Machine Code (e.g., ENIAC): Electronic Numerical
Integrator and Computer Written in binary, directly executed by the
hardware
• - 1950s : Assembly Language (e.g., ASM): Low-level, symbolic
representation of machine code
• - 1960s : High-Level Languages (e.g., FORTRAN, COBOL): Abstracted
from hardware; used for scientific and business applications
• - 1970s : Structured Programming (e.g., C, Pascal): Introduced
modularity and control structures
• - 1980s : Object-Oriented Programming (e.g., C++, Smalltalk):
Focused on objects and reusable components
• - 1990s-Present : Multi-paradigm (e.g., Python, Java, C#): Supports
multiple paradigms for flexibility
Traditional Programming Concepts
• - Syntax and Semantics : Syntax refers to the structure (e.g.,
grammar); semantics is the meaning of the code
• - Variables : Named storage that holds data values (e.g., int x
= 5)
• - Control Structures : Direct the flow of execution (e.g., loops,
conditionals)
• - Data Types : Define the kind of data (e.g., int, float, char)
• - Functions : Blocks of reusable code with parameters and
return values

• Example:
• int add(int a, int b) {
• return a + b;
• }
Programming Paradigms
• - Imperative : Code describes how to achieve a task
step-by-step (e.g., C)
• - Declarative : Focuses on what the program should
accomplish, not how (e.g., SQL for database queries)
• - Functional : Uses mathematical functions; avoids
changing state (e.g., Haskell, Lisp)
• - Object-Oriented : Structures programs into classes
and objects (e.g., Java, Python)
• - Example of OOP: BankAccount object with
attributes like balance and methods like
deposit/withdraw
Imperative vs. Declarative Programming
Imperative Programming :
- Specifies how to perform tasks step-by-step.
- Focuses on the process (control flow, loops, instructions).
- Gives full control to the programmer over execution flow.
- Example (Python) :
```python
numbers = [1, 2, 3, 4, 5]
total = 0
for num in numbers:
total += num
print(total)
Imperative vs. Declarative Programming
• - Declarative Programming :
• - Specifies what the outcome should be without
focusing on how .
• - Focuses on the result , hiding execution details.
• - Relies on the language/framework to handle the
implementation.
• - Example (SQL) :
• ```sql
• SELECT SUM(column) FROM table;
Procedural Units
• - Definition : Grouped code blocks for a specific
functionality (e.g., functions, subroutines)
• - Features : Promotes code reusability, modularity,
and easier debugging
• - Benefits :
• - Reduces redundancy
• - Simplifies large programs

• Example in C:
• void greet() {
• printf('Hello, World!');
• }
Language Implementations
• 1. Compiled Languages : Converts source code into
machine code before execution (e.g., C, C++). Faster
execution but requires recompilation after changes.
• 2. Interpreted Languages : Executes code line-by-
line without prior compilation (e.g., Python, Ruby).
Slower but more flexible.
• 3. Hybrid Languages : Compiles into intermediate
bytecode, then interpreted or executed by a virtual
machine (e.g., Java - Bytecode + JVM).
Object-Oriented Programming
(OOP)
• - Key Principles :
• - Encapsulation: Bundling data and methods
(e.g., private attributes)
• - Inheritance: Creating a new class from an
existing class
• - Polymorphism: Same method name with
different implementations
• - Abstraction: Hiding complexity, exposing
only essential details
Summary
• - Evolution of programming languages
• - Core concepts for writing code
• - Paradigms guide how programs are
structured
• - Procedural and Object-Oriented approaches
dominate

You might also like