This is a TL;DR of an hour-long presentation (video and slide deck) by Anjana Vakil on programming paradigms, in light of the war between functional and object-oriented fans. I think it’s safe to say that a paradigm shift is underway — at least in public discourse, if not in practice — regarding which one is to be the dominant trend in software development.
What Are Paradigms?
They are models that enable and define the act of programming.
All models are wrong; some models are useful. —George E. P. Box
Is the model illuminating and useful?
An example of models is the history of the way humans have viewed the universe:
- Newton: the universe was like a massive clock built by a creating god and set into motion. The force of universal gravitation makes every pair of bodies in the universe attract each other.
- Einstein: the universe is both spatially infinite and temporally infinite, and space is neither expanding nor contracting.
- Newer views: the universe is expanding, etc.
Each paradigm supports a set of concepts that makes it the best for a certain kind of problem. —Peter Van Roy
What can a paradigm teach us?
- Imperative: explicit, focus on and understand implementation
- Declarative: abstract, understand domain
- Object-oriented: encapsulate, communicate
- Functional: specialize, transform data
If the advancement of the general art of programming requires the continuing invention and elaboration of paradigms, advancement of the individual programmer requires that they expand their repertory of paradigms. —Robert W. Floyd
We, as a species, figured out how to electrify rocks and make them do what we want.—Anjana Vakil
Characteristics: micromanaged and explicit, must be done in a specific way in every detail
- Follow my commands
- In the order I gave them
- Remember state
Advocate: Alan Kay
State and data:
- Share data = no
- Mutable state = yes
Characteristics: organic, cellular, ephemeral, mutable
- Keep your state to yourself
- Receive my messages
- Calling methods = objects sending messages to each other
- Respond as you see fit
Examples: Lisp, Scheme
Advocate: Alonzo Church
State and data:
- Share data = yes
- Mutable state = no
Characteristics: mathematical, physical, material, immutable
- Mutable state is dangerous
- Pure functions are safe
- Data goes in, data comes out
Examples: SQL, Prolog
Characteristics: logic puzzle
- These are the facts
- This is what I want
- I don’t care how you do it