Imperative, declarative, object-oriented, functional, logic and event-driven paradigms and how languages combine them.
34 cards · basic cards · AI-written, checked twice. Edit anything.
- What is imperative programming?
Show answer
A paradigm where you specify the exact steps and instructions a computer must execute to solve a problem, focusing on how to do something rather than what the end result should be.
- What is declarative programming?
Show answer
A paradigm where you describe what you want the result to be without explicitly stating how the computer should achieve it.
- What is object-oriented programming (OOP)?
Show answer
A paradigm that organizes code around objects that contain both data (attributes) and behavior (methods), modeling real-world entities and their interactions.
- What is functional programming?
Show answer
A paradigm that treats computation as the evaluation of mathematical functions, emphasizing immutability and avoiding changing state and side effects.
- What is logic programming?
Show answer
A paradigm where you state facts and rules about a problem, and the computer uses logical inference to find solutions that satisfy those rules.
- What is event-driven programming?
Show answer
A paradigm where the program flow is determined by user actions, messages, or sensor outputs, with code triggered in response to specific events.
- How does imperative programming answer the question 'how do I accomplish this task'?
Show answer
By providing explicit sequences of commands and state changes that transform initial conditions into the desired result.
- How does declarative programming answer the question 'what do I want'?
Show answer
By specifying the properties and constraints of the desired result, leaving implementation details to the underlying system or compiler.
- What is immutability in functional programming?
Show answer
The principle that once a value is created, it cannot be changed. Instead of modifying data, functional programs create new data structures with the desired changes.
- What are first-class functions?
Show answer
Functions treated as values that can be passed as arguments to other functions, returned from functions, and assigned to variables, central to functional programming.
- What is encapsulation in object-oriented programming?
Show answer
The bundling of data (attributes) and methods (functions) into a single unit called an object, along with hiding internal details and controlling access through public interfaces.
- What is the relationship between classes and objects in OOP?
Show answer
A class is a blueprint or template that defines the structure and behavior, while an object is a specific instance of that class with its own data values.
- What is unification in logic programming?
Show answer
The process of making two terms identical by finding values for variables, used to match patterns and solve equations in logic programs.
- What is backtracking in logic programming?
Show answer
A search mechanism where the program retreats from a failed path and tries alternative solutions by undoing variable bindings and exploring other possibilities.
- What triggers code execution in event-driven programming?
Show answer
External or internal events such as user interactions (clicks, key presses), system signals, messages, or sensor data that activate registered event handlers or callbacks.