ALGOL and Pascal
Notes from the COMP2007 Lecture, and online resources.
Historical Context
- 1950s programming: Fortran was successful but machine-dependent (IBM 704).
- Need for change: Desire for a machine-independent, universal language → birth of ALGOL.
- Developed by committee → lengthy discussions on what to include/exclude.
- Main goal: Create a standard usable across different machines.
ALGOL (Algorithmic Language)
Key Innovations
- Machine independence → portable code.
- BNF (Backus–Naur Form) used to formally describe syntax (~15 pages of rules).
- Nested control structures (not just nested loops).
- Block structure & scope:
begin ... endblocks define scope.- Scope: Where variables exist and are accessible.
- Static scope: Known from reading code (compile-time).
- Dynamic scope: Determined during execution (run-time).
- Types of statements:
- Declarative (declare variables/types)
- Imperative (perform actions)
- No built-in I/O in the standard → machine-specific implementations.
- Syntax regularity:
- One meaning per symbol.
- Assignment:
:= - Equality test:
=
- Reserved words: Prevent misuse (e.g.,
ifcan’t be a variable name). - No restriction on variable name length.
- Data types:
- Integer, real, boolean, arrays (with arbitrary index bounds, e.g.,
-5..5) - Strong typing.
- Integer, real, boolean, arrays (with arbitrary index bounds, e.g.,
- Recursion supported.
- Parameter passing:
- Pass by value (copy)
- Pass by name (substitution-like, late binding) — tricky concept.
- Pointers:
- Variables holding memory addresses.
- Could cause issues (dangling pointers, memory leaks).
- Activation Records (Stack Frames):
- Contain info needed for a function call: return address, local variables, links to other frames.
- Static link: Follows lexical scope (compile-time structure).
- Dynamic link: Follows call chain (run-time order).
Static vs Dynamic Concepts
- Static scope: Determined at compile time by code structure.
- Dynamic scope: Determined at run time by the calling sequence.
- Static typing: Variable type fixed at compile time.
- Dynamic typing: Type determined at run time (e.g., Python
x = 5→ int, thenx = 5.5→ float).
Pascal
- Developed to simplify ALGOL → more beginner-friendly, effective for teaching.
- Still used today in some legacy systems.
Main Features
- Single main program block.
- Readable, well-structured syntax.
- Supports nested procedures/functions.
- Various data types: enumerated, subrange, sets, records (like C structs), pointers.
- Control structures similar to modern languages.
- Parameter passing similar to ALGOL.
Strength: Clear, structured, easy to learn.
Weakness: Can introduce complexity through deep nesting, multiple binding methods.
Why ALGOL & Pascal Matter
- ALGOL = “grandmother of modern languages” — influenced C, Java, Python, etc.
- Features we now take for granted (block structure, scope, recursion, reserved words, strong typing) originated here.
- Pascal showed that simplifying a powerful language can make it more usable for teaching and structured programming.
Leave a comment