Unit I: History & Foundations of Programming
Languages
COMPREHENSIVE ACADEMIC NOTES • COMPLETE SYLLABUS COVERAGE
1. History and Evolution of Programming Languages
The evolution of programming languages mirrors the progression of computer hardware,
moving from low-level, machine-centric instructions to highly abstract, human-readable
environments. This development is fundamentally categorized into generations:
• First Generation (1G): Machine Language. Written entirely in binary code (0s and 1s). It
executed directly by the hardware without translation but was highly error-prone and
platform-dependent.
• Second Generation (2G): Assembly Language. Introduced mnemonics (such as MOV, ADD,
SUB) to substitute binary strings. It required an Assembler to map instructions to machine
code.
• Third Generation (3G): High-Level Languages. Built using structured, English-like syntax.
Key milestones include FORTRAN (Formula Translation, 1957) for scientific computing,
COBOL (Common Business-Oriented Language, 1959) for business applications, and later C
(1972), which balanced high-level abstraction with low-level systems access.
• Fourth Generation (4G): Declarative Languages. Specifying what to do rather than how to
do it, heavily utilized in database interactions (e.g., SQL) and report generation.
2. Role of Programming Languages
Programming languages serve as the primary conceptual framework and bridge between human
problem-solving models and automated execution environments. Their roles include:
• Abstraction Mechanism: Hiding complex hardware mechanics (registers, memory addresses,
bus cycles) behind accessible syntax structures.
• Software Engineering Foundation: Supporting maintainability, encapsulation, portability,
and safety features that allow large teams to collaborate on expansive codebases.
• Cognitive Framework: Structuring how software architects conceptualize problems—
different languages encourage distinct methods of decomposing algorithmic tasks.
3. Language Translation Architecture
Computers cannot directly interpret high-level languages. A structured transformation pipeline
converts raw human-readable source code into native machine execution units.
Unit I Notes: Programming Paradigms & Logic 1
[ Source Code ] → [ Lexical Analyzer ] → [ Syntax Analyzer (Parser) ] →
[ Semantic Analyzer ] → [ Intermediate Code Generator ] → [ Intermediate Optimizer ] →
[ Code Generator ] → [ Object/Machine Code ]
The Compilation Phases
1. Lexical Analysis (Scanner): Breaks down the raw input stream of characters into meaningful
atomic units called Tokens (keywords, identifiers, literals, operators). Eliminates whitespaces
and comments.
2. Syntax Analysis (Parser): Grouping tokens into structured grammatical forms. Constructs a
hierarchical Abstract Syntax Tree (AST) based on the operational grammar rules of the
target language.
3. Semantic Analysis: Verifies the AST against structural constraints of the language rules. It
performs Type Checking, ensuring operations are legal for the applied data types (e.g.,
preventing the addition of a string to an integer).
4. Intermediate Code Generation: Translates the verified AST into an abstract, hardware-
independent low-level language format (e.g., Three-Address Code) to isolate language features
from target hardware structures.
5. Code Optimization: Transforms the intermediate code to run more efficiently, reducing
memory footprint or cycle consumption without altering output.
6. Code Generation: Maps the optimized intermediate code to the exact target physical
architecture machine code or binary object files.
Translators: Compilers vs. Interpreters
Feature Compiler Interpreter
Translates the entire source document
Execution Translates and executes line-by-line or
into an independent machine file before
Method statement-by-statement at runtime.
execution.
Slower total execution; translation
Faster execution post-compilation, as
Speed occurs continuously alongside
translation is already completed.
execution.
Stops execution immediately upon
Error Reports all syntactic errors at once after
encountering the first runtime or
Handling scanning the complete file.
syntax error.
Target
C, C++, Rust, Go Python, Ruby, PHP
Examples
Unit I Notes: Programming Paradigms & Logic 2
4. Core Syntax and Semantics
A programming language definition relies on two precise boundaries:
• Syntax: The formal rules governing structural arrangement and composition of valid
statements. It dictates form, but ignores underlying logic.
• Semantics: The actual semantic meaning, logic, and operational behavior behind structurally
legal statements.
Structural vs Logical Distinction
The statement int x = "apple"; is syntactically flawless under standard rules for variable
layout, but fails semantically during static compilation because a string literal cannot match
an integer data type container.
5. Basic Concepts: Types, Variables, and Data Structures
Data Types
Data types specify the storage scale, layout boundaries, and valid operation matrices for
information points:
• Primitive Types: Hardwired directly to base architecture primitives:
◦ Integers: Whole numbers (e.g., 8-bit, 32-bit signed/unsigned).
◦ Floating-Point: Real fractional representations via standard systems like IEEE 754.
◦ Characters & Booleans: Standard individual encoding units (ASCII/Unicode) and strict
binary flags (True/False).
• Structured / Composite Data Types: Aggregated components built from primitives:
◦ Arrays: Homogeneous contiguous blocks of elements mapped by an index.
◦ Records/Structures: Heterogeneous collections grouping related fields under single
namespaces.
Variables and Constants
• Variables: Named, allocated memory spaces whose evaluated contents can dynamically
transition throughout the lifecycle of application execution.
• Constants: Static identifiers bound to concrete values that remain structurally unalterable
post-declaration.
Unit I Notes: Programming Paradigms & Logic 3
Subprogram Control Structures
Subprograms (functions, procedures, routines) break software into modular blocks. Control
execution follows structured activation protocols:
• Argument Passing: Evaluated via Call-by-Value (passing a local isolated copy) or Call-by-
Reference (passing a direct memory link to the original variable).
• Activation Records (Stack Frames): Memory units dynamically loaded onto the execution
call stack whenever a subprogram triggers. They hold localized variables, execution
parameters, and return points, clean-unwinding on return.
6. Core Programming Paradigms
Paradigms define the operational style and architectural patterns used to build computational
models.
Procedural Paradigm
Focuses on breaking a program down into linear procedures or sequential steps. The model
centers on changing data values sequentially using explicit, imperative command chains (e.g., C,
Pascal).
Functional Paradigm
Treats computation as the evaluation of mathematical functions, avoiding mutable state data
changes or side effects. It relies on pure functions, immutable state logic, and high-order
expression mappings (e.g., Haskell, Lisp).
Logic Paradigm
Employs formal mathematical relations and predicate calculus. Programs do not state explicit
operational paths; instead, they define factual assertions and query conditions, leaving the
execution engine to deduce truths (e.g., Prolog).
7. Algorithmic Problem-Solving Logic
Before writing code, complex problems are organized into formal, precise logical workflows
using structured algorithms.
Characteristics of an Algorithm
To be considered correct and valid, a computational algorithm must fulfill five foundational
constraints:
1. Finiteness: The algorithm must terminate after a countable, limited sequence of execution
steps.
Unit I Notes: Programming Paradigms & Logic 4
2. Definiteness: Every action step must be clear, precise, and completely unambiguous.
3. Input: Must accept zero or more valid external input parameters.
4. Output: Must produce at least one defined final result that answers the problem.
5. Effectiveness: Steps must be basic enough to be carried out exactly using paper and pencil in
a finite amount of time.
Flowchart Standard Reference Elements
Flowcharts visually map algorithmic control flow using standard symbolic elements:
• Oval / Capsule: Terminal points marking the exact START or END of a process.
• Parallelogram: Handles Input and Output tasks (e.g., READ X, PRINT Y).
• Rectangle: Indicates an internal processing step, evaluation, or variable assignment (e.g., Total
= A + B).
• Diamond: Represents a conditional decision point, branching execution paths along valid
binary routes (e.g., True/False, Yes/No).
• Arrows: Direct flow lines showing the exact path of execution.
Unit I Notes: Programming Paradigms & Logic 5