What is the fourth paradigm?

luqui on 2005-11-19T08:48:57

At OSCON, Ovid cited the four paradigms like this:

* Procedural * Object-oriented * Functional * Logical

I've also seen this list in several other places. However, I think this mixes up its concepts a bit. There are really two orthogonal properties acting here: the abstraction style and the control style.

The abstraction style refers to how you break up the logic of your program. It falls into two categories:

* Procedural * Object-oriented

The difference is what you put in name. In the procedural style, you put mappings (functions) or actions (procedures) into names. In the object-oriented style, you put things (objects) and messages (methods) into names.

The control style describes how the control flows through the program. It falls into three categories:

* Imperative * Functional * Logical

In the imperative style, you are instructing the program to do things, to manipulate the state of the world. In the functional style, you are instructing the program to compute things, to evaluate a very complicated mathematical function. In the logical style, you are instructing the program to find objects that satisfy a complex condition.

Here's a table of common languages:

Abstraction | Procedural    | OO
Control     +---------------+------------
Imperative  | C             | C++, Java
Functional  | Scheme, ML    | OCaml, Haskell, Lisp (under CLOS)
Logical     | Prolog        | Curry


A lot of these languages actually cut across the table in various ways. If a language is capable of OO, I've put it in the OO section, even if it has procedural capabilities as well. In fact, all of these languages have procedural capabilities except Java (which still does, but tries to deny it).

Anyway, what I'm wondering has to do with the control style. Three is a strange number for a classification. Usually classifications are powers of two: combinations of orthogonal binary capabilities. What are the orthogonal capabilities in the control style? What's the combination of those that has gone unnoticed?


Maybe logical are subset of functional?

Crag on 2005-11-27T20:24:42

I'm not as deeply into languages as I'd like to be, but my understanding is that functional and logical languages both express activities in terms of relationships and transformations.

I don't think it's useful to include logical programming as a full-fledged programming paradigm. I'd say it's more of a design pattern like state machines, stack-based evaluators and the like. I think we're just being mis-led by the crazy people who went as far as to design entire languages around the pattern.