Fiche de révision : Programming Language Paradigms

Course Outline

  1. Paradigms, Languages, and State
  2. Imperative and Declarative Taxonomy
  3. Paradigm Comparison Dimensions
  4. Imperative and Declarative Code
  5. Architectural Trade-Offs
  6. Referential Transparency and Side Effects

1. Paradigms, Languages, and State

Key Concepts & Definitions

  • Programming paradigm : A fundamental style, mindset, or philosophical approach for structuring and organizing computer code through specific rules, abstractions, and computational models.
  • State : The data stored in memory at a given moment during program execution.
  • State mutation : The act of changing memory values in place over time during program execution.

Essential Points

★ Must-know

📌 A programming language is a tool such as Python, C++, or Haskell, whereas a programming paradigm is the philosophy guiding how that tool structures computation.

Further detail

  • Most modern programming languages are multi-paradigm and can support object-oriented, functional, and procedural styles simultaneously.

Memory Hook

Philosophy, tool, memory

2. Imperative and Declarative Taxonomy

Key Concepts & Definitions

  • Imperative paradigm : Specifies how to compute a solution step by step by explicitly manipulating program state.
  • Declarative paradigm : Specifies what result is required without detailing the step-by-step execution process.

Essential Points

★ Must-know

📌 The two primary programming paradigm branches are imperative and declarative, classified according to how they handle state and control flow.

Further detail

  • Procedural and object-oriented programming are sub-paradigms of the imperative branch.

  • Functional programming, logic programming, and database querying are sub-paradigms of the declarative branch.

Memory Hook

HOW versus WHAT

3. Paradigm Comparison Dimensions

Essential Points

★ Must-know

📌 Imperative programs generally use mutable state, whereas declarative programs use immutable state whose data cannot be modified in place.

📌 Imperative control flow commonly uses for and while loops, explicit if branching, and jumps, whereas declarative control flow uses recursion, higher-order functions, and pattern matching.

📌 Side effects are common and expected in imperative programming, while declarative programming minimizes or completely eliminates them.

Further detail

  • Imperative programming uses statements, procedures, and objects as primary units, whereas declarative programming uses expressions, pure functions, and mathematical rules.

  • Representative imperative languages are C, C++, Java, and Pascal, while representative declarative languages are Haskell, Prolog, SQL, and HTML.

Memory Hook

State, flow, effects

4. Imperative and Declarative Code

Essential Points

★ Must-know

  • For the array [1, 2, 3, 4, 5], the imperative C solution initializes a mutable total to 0, iterates with an explicit loop, tests each element with a conditional, adds odd elements to total in place, and returns the total.

  • For the same array, the declarative Haskell solution computes the result as sum (filter odd numbers), expressing a transformation without mutable loops or variables.

Further detail

  • The imperative and declarative implementations both filter out even numbers and sum the remaining odd numbers from [1, 2, 3, 4, 5].

Memory Hook

Loop versus transformation

5. Architectural Trade-Offs

Essential Points

📌 Matching a programming paradigm to its domain can reduce bug density by aligning the paradigm with the system's requirements.

📌 Using functional immutability in multithreaded systems can prevent race conditions by avoiding in-place state changes.

  • Modern enterprise architectures can combine object-oriented models for domain entities, functional pipelines for ETL data-stream processing, and declarative markup such as HTML or YAML for user interfaces and setup configurations.

Memory Hook

Choose by domain

6. Referential Transparency and Side Effects

Key Concepts & Definitions

  • Referential transparency : A function is referentially transparent when it can be replaced by its resulting value without changing program behavior.

Essential Points

📌 The function add(x, y) that returns x + y is referentially transparent because it returns the same result for the same inputs and has no side effects.

📌 The function add_with_log(x, y), which prints "Adding" before returning x + y, is not referentially transparent because console output is an I/O side effect.

Memory Hook

Same input, same result

Synthesis Tables

Imperative versus Declarative Paradigms

DimensionImperativeDeclarative
Core philosophyTell the computer how to solve a problem step by stepState what result is required
State managementMutable stateImmutable state
Control flowLoops, explicit branching, and jumpsRecursion, higher-order functions, and pattern matching
Side effectsCommon and expectedMinimized or eliminated
Primary unitsStatements, procedures, and objectsExpressions, pure functions, and mathematical rules
Representative languagesC, C++, Java, PascalHaskell, Prolog, SQL, HTML

Common Pitfalls & Confusions

  1. A paradigm is the philosophy behind a language, not the language itself.
  2. Imperative programming emphasizes execution steps rather than only the desired result.
  3. Immutable state does not mean that values cannot be used to create new results.
  4. The loop-based implementation describes how the computation proceeds.
  5. Immutability helps prevent race conditions but is not presented as the only architectural consideration.
  6. A deterministic return value alone is insufficient if the function also produces side effects.
  7. A language and a paradigm are not interchangeable terms.

Teste tes connaissances

Teste tes connaissances sur Programming Language Paradigms avec 18 questions à choix multiples et corrections détaillées.

1. Which statement best defines a programming paradigm in terms of code structure?

2. What distinguishes a programming language from a programming paradigm?

Faire le QCM →

Révisez avec les flashcards

Mémorisez les concepts clés de Programming Language Paradigms avec 30 flashcards interactives.

What is a programming paradigm?

A fundamental style or approach for structuring computer code.

What distinguishes a programming language from a programming paradigm?

A language is a tool, while a paradigm is the guiding philosophy.

What is true about most modern programming languages regarding paradigms?

They support multiple paradigms like object-oriented, functional, and procedural.

Voir les flashcards →

Cours similaires

Crée tes propres fiches de révision

Importe ton cours et l'IA génère fiches, QCM et flashcards en 30 secondes.

Générateur de fiches