Programming Paradigms

SSI

Programming Paradigms

  • What is a paradigm?
  • What paradigms exist?
  • How do I know which one to use?

Paradigms

In science and philosophy, a paradigm … is a distinct set of concepts or thought patterns

– Wikipedia - Paradigm

A Brief History

Imperative Family

Code describes how data processing should happen

Structured Programming

Code should be grouped into logical blocks

  • Imperative family
  • Early example: Algol (1958)

Procedural Programming

Code should be grouped into procedures performing a single task

  • Derived from Structured Programming
  • Early examples: FORTRAN II (1958), COBOL (1959)

Object Oriented Programming

Data should be structured. Code belongs with data

  • Derived from Procedural Programming
  • Early examples: Simula (1967), Smalltalk (1972)

Declarative Family

Code describes what data processing should happen

Functional Programming

Functions are mathematical operations. Code is data

  • Declarative family
  • Early examples: Lisp (1958)

FizzBuzz

1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, …

FizzBuzz

Implementations of FizzBuzz in C-family languages taken from Rosetta Code under GPL Free Documentation License 1.2

FizzBuzz in C

FizzBuzz in C

FizzBuzz in Java

FizzBuzz in Java

FizzBuzz in JavaScript (ES6)

FizzBuzz in JavaScript