Ultimate Survey of Programming
Languages Study Guide
Your One-Stop Resource to Ace the Exam
Table of Contents
1. 1. Introduction to Programming Languages
2. 2. Formal Grammar & Syntax
3. 3. Programming Paradigms
4. 4. Von Neumann Architecture
5. 5. Compilers vs. Interpreters
6. 6. Exam Tips
7. Appendix
1. Introduction to Programming Languages
What is a Programming Language?
Layman’s Explanation:
A programming language is like a translator between humans and computers. You write
instructions in a structured way (code), and the computer executes them.
Technical Explanation:
A formal system of syntax and semantics used to instruct a computer to perform specific
tasks.
Examples:
- Python (easy readability, great for beginners)
- C (low-level, used in operating systems)
- Prolog (logic-based, used in AI)
Generations of Programming Languages
Generation Key Features Examples
1GL Binary (0s & 1s), machine-dependent Machine Code
2GL Assembly language (mnemonics like MOV, ADD) x86 Assembly
3GL High-level, structured (if-else, loops) C, Java, Python
4GL Non-procedural, database queries SQL, MATLAB
5GL AI-driven, declarative constraints Prolog, LISP
Fun Fact: 1GL was error-prone because programmers had to manually toggle switches to
input binary!
5GL lets you define what to solve (e.g., "Find all prime numbers") rather than how.
2. Formal Grammar & Syntax
What is Grammar in Programming?
Layman’s Explanation:
Grammar is like the 'rules of the road' for writing code. Just as English has grammar rules,
programming languages have rules for how code must be structured.
Technical Explanation:
- Terminals (T): Basic symbols (e.g., +, if, 5)
- Non-Terminals (N): Placeholders for patterns (e.g., <expression>, <statement>)
- Production Rules (P): How non-terminals expand
Example Grammar Rule:
S → aSb | ε
Why It Matters in Compilation?
- Lexical analyzer breaks code into tokens (e.g., int x = 5; → [int, x, =, 5, ;])
- Syntax analyzer checks if tokens follow grammar rules
3. Programming Paradigms
Imperative Programming (C, Python)
How It Works:
- Follows step-by-step instructions
- Uses variables, loops, and functions
int sum = 0;
for (int i = 1; i <= 10; i++) {
sum += i;
}
printf("Sum: %d", sum);
Functional Programming (Haskell, LISP)
Key Idea:
- No side effects
- Uses recursion instead of loops
sumList [] = 0
sumList (x:xs) = x + sumList xs
Logic Programming (Prolog)
How It Works:
- Based on facts and rules
- The interpreter finds solutions by logical inference
parent(john, mary).
ancestor(X, Y) :- parent(X, Y).
?- ancestor(john, mary).
4. Von Neumann Architecture
Key Components:
- CPU (ALU + Control Unit)
- Memory (RAM)
- I/O Devices
Why It Matters: Programs are now stored in memory, making them flexible and reusable.
5. Compilers vs. Interpreters
Compiler vs. Interpreter Comparison:
- Compiler: Translates entire code at once, faster, errors shown after full run
- Interpreter: Executes line-by-line, slower, errors shown immediately
Examples:
- Compiler: C, Java
- Interpreter: Python, JavaScript
How a Compiler Works:
Lexical Analysis → Syntax Analysis → Semantic Analysis → Code Generation
6. Exam Tips
✅ Memorize Key Definitions:
Syntax = Structure
Semantics = Meaning
✅ Understand Paradigm Differences:
OOP (Java) = Objects + Inheritance
Functional (Haskell) = Pure functions + Recursion
✅ Practice Tracing Code
Final Words
This guide covers everything from grammar to compilers to paradigms. Focus on:
- Key differences between languages
- How compilation works
- Von Neumann’s role in modern computing
You’ve got this! 🚀 Good luck on your exam!
Appendix
Quick Reference Cheat Sheet
Sample Exam Questions & Answers