Describe the procedural, object-oriented and functional paradigms. Show how the same small task, totalling the marks of students who passed, might look in each style.
Show the explanation
A paradigm is a style of organising code. Most modern languages (Python, Java, C++, JavaScript, Kotlin) support several, and good code mixes them.
Procedural (C, early BASIC, scripts): a program is a sequence of steps and procedures that operate on data.
total = 0
for s in students:
if s["marks"] >= 40:
total += s["marks"]Simple and direct. In large systems, shared mutable data becomes hard to manage.
Object-oriented (Java, C#, C++): bundle data and the behaviour that belongs to it into objects. The four pillars are encapsulation, abstraction, inheritance and polymorphism.
class Student:
def __init__(self, name, marks): self.name, self.marks = name, marks
def passed(self): return self.marks >= 40
class Batch:
def __init__(self, students): self._students = students
def pass_total(self): return sum(s.marks for s in self._students if s.passed())This models real-world entities well and keeps rules in one place (here, passed()). The risk is deep inheritance hierarchies and over-engineering.
Functional (Haskell, Clojure, F#, and much of modern JavaScript and Scala): build programs from pure functions (same input gives the same output, with no side effects), immutable data and higher-order functions such as map, filter and reduce.
from functools import reduce
total = reduce(lambda acc, m: acc + m, filter(lambda m: m >= 40, map(lambda s: s["marks"], students)), 0)
# idiomatic Python: sum(m for s in students if (m := s["marks"]) >= 40)Pure functions are easy to test and safe to run in parallel. Some problems are awkward to express without mutable state, and it can take time to learn.
Others worth naming: declarative code says what you want, not how (SQL, HTML, regular expressions). Event-driven code reacts to events (GUIs, Node.js). Logic programming uses facts and rules (Prolog).
Interview angle: choose the style that fits the problem. Use OOP for modelling domain entities with behaviour, functional style for data transformations and concurrency, and procedural code for short scripts.
Original UniCircle question. Last reviewed 22 Oct 2026.
